Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

octeontx2-af: Fix reference count issue in rvu_sdp_init()

pci_get_device() will decrease the reference count for the *from*
parameter. So we don't need to call put_device() to decrease the
reference. Let's remove the put_device() in the loop and only decrease
the reference count of the returned 'pdev' for the last loop because it
will not be passed to pci_get_device() as input parameter. We don't need
to check if 'pdev' is NULL because it is already checked inside
pci_dev_put(). Also add pci_dev_put() for the error path.

Fixes: fe1939bb2340 ("octeontx2-af: Add SDP interface support")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: Saeed Mahameed <saeed@kernel.org>
Link: https://lore.kernel.org/r/20221123065919.31499-1-wangxiongfeng2@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Xiongfeng Wang and committed by
Paolo Abeni
ad17c2a3 6aae1bcb

+5 -2
+5 -2
drivers/net/ethernet/marvell/octeontx2/af/rvu_sdp.c
··· 62 62 pfvf->sdp_info = devm_kzalloc(rvu->dev, 63 63 sizeof(struct sdp_node_info), 64 64 GFP_KERNEL); 65 - if (!pfvf->sdp_info) 65 + if (!pfvf->sdp_info) { 66 + pci_dev_put(pdev); 66 67 return -ENOMEM; 68 + } 67 69 68 70 dev_info(rvu->dev, "SDP PF number:%d\n", sdp_pf_num[i]); 69 71 70 - put_device(&pdev->dev); 71 72 i++; 72 73 } 74 + 75 + pci_dev_put(pdev); 73 76 74 77 return 0; 75 78 }