Commit 56195372 authored by Yang Yingliang's avatar Yang Yingliang Committed by Jakub Kicinski

net: pch_gbe: fix pci device refcount leak while module exiting

As comment of pci_get_domain_bus_and_slot() says, it returns
a pci device with refcount increment, when finish using it,
the caller must decrement the reference count by calling
pci_dev_put().

In pch_gbe_probe(), pci_get_domain_bus_and_slot() is called,
so in error path in probe() and remove() function, pci_dev_put()
should be called to avoid refcount leak. Compile tested only.

Fixes: 1a0bdadb ("net/pch_gbe: supports eg20t ptp clock")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221117135148.301014-1-yangyingliang@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d6660880
...@@ -2460,6 +2460,7 @@ static void pch_gbe_remove(struct pci_dev *pdev) ...@@ -2460,6 +2460,7 @@ static void pch_gbe_remove(struct pci_dev *pdev)
unregister_netdev(netdev); unregister_netdev(netdev);
pch_gbe_phy_hw_reset(&adapter->hw); pch_gbe_phy_hw_reset(&adapter->hw);
pci_dev_put(adapter->ptp_pdev);
free_netdev(netdev); free_netdev(netdev);
} }
...@@ -2534,7 +2535,7 @@ static int pch_gbe_probe(struct pci_dev *pdev, ...@@ -2534,7 +2535,7 @@ static int pch_gbe_probe(struct pci_dev *pdev,
/* setup the private structure */ /* setup the private structure */
ret = pch_gbe_sw_init(adapter); ret = pch_gbe_sw_init(adapter);
if (ret) if (ret)
goto err_free_netdev; goto err_put_dev;
/* Initialize PHY */ /* Initialize PHY */
ret = pch_gbe_init_phy(adapter); ret = pch_gbe_init_phy(adapter);
...@@ -2592,6 +2593,8 @@ static int pch_gbe_probe(struct pci_dev *pdev, ...@@ -2592,6 +2593,8 @@ static int pch_gbe_probe(struct pci_dev *pdev,
err_free_adapter: err_free_adapter:
pch_gbe_phy_hw_reset(&adapter->hw); pch_gbe_phy_hw_reset(&adapter->hw);
err_put_dev:
pci_dev_put(adapter->ptp_pdev);
err_free_netdev: err_free_netdev:
free_netdev(netdev); free_netdev(netdev);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment