Skip to content

Commit ad17c2a

Browse files
fenghusthuPaolo Abeni
authored andcommitted
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: fe1939b ("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>
1 parent 6aae1bc commit ad17c2a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • drivers/net/ethernet/marvell/octeontx2/af

drivers/net/ethernet/marvell/octeontx2/af/rvu_sdp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,18 @@ int rvu_sdp_init(struct rvu *rvu)
6262
pfvf->sdp_info = devm_kzalloc(rvu->dev,
6363
sizeof(struct sdp_node_info),
6464
GFP_KERNEL);
65-
if (!pfvf->sdp_info)
65+
if (!pfvf->sdp_info) {
66+
pci_dev_put(pdev);
6667
return -ENOMEM;
68+
}
6769

6870
dev_info(rvu->dev, "SDP PF number:%d\n", sdp_pf_num[i]);
6971

70-
put_device(&pdev->dev);
7172
i++;
7273
}
7374

75+
pci_dev_put(pdev);
76+
7477
return 0;
7578
}
7679

0 commit comments

Comments
 (0)