net: thunderx: fix PTP device ref leak in nicvf_probe()
PATCH 1/1 net: thunderx: fix PTP device ref leak in nicvf_probe()
cavium_ptp_get() acquires a reference to the PTP PCI device through pci_get_device(). If any initialization step fails after cavium_ptp_get(), the PTP PCI device reference is leaked. Add a common error path to release the PTP reference before returning from probe failures.
--- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/thunder/nicvf_main.c +6 -2
@@ -2109,8 +2109,10 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } err =pci_enable_device (pdev); -if (err) -return dev_err_probe (dev, err,"Failed to enable PCI device\n" ); +if (err) { + err =dev_err_probe (dev, err,"Failed to enable PCI device\n" ); + goto err_put_ptp; + } err =pci_request_regions (pdev,DRV_NAME );if (err) {
@@ -2264,6 +2266,8 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)pci_release_regions (pdev); err_disable_device:pci_disable_device (pdev); +err_put_ptp: +cavium_ptp_put (ptp_clock);return err; }
Signature · 1 line
2.25.1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Mon, 25 May 2026 16:26:11 +0800 you wrote:
cavium_ptp_get()acquires a reference to the PTP PCI device throughpci_get_device(). If any initialization step fails aftercavium_ptp_get(), the PTP PCI device reference is leaked. Add a common error path to release the PTP reference before returning from probe failures.Fixes 4a8755096466 ("net: thunderx: add timestamping support")Signed-off-by Haoxiang Li <[email protected]>[...]
Here is the summary with links:
- net: thunderx: fix PTP device ref leak in nicvf_probe()
https://git.kernel.org/netdev/net-next/c/2bcf59eefb9f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html