Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: thunderx: fix PTP device ref leak in nicvf_probe()
@ 2026-05-25  8:26 Haoxiang Li
  2026-05-27  2:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-05-25  8:26 UTC (permalink / raw)
  To: sgoutham, andrew+netdev, davem, edumazet, kuba, pabeni,
	richardcochran, pombredanne, aleksey.makarov
  Cc: linux-arm-kernel, linux-kernel, netdev, Haoxiang Li, stable

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.

Fixes: 4a8755096466 ("net: thunderx: add timestamping support")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 0b6e30a8feb0..d794aec80821 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -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;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: thunderx: fix PTP device ref leak in nicvf_probe()
  2026-05-25  8:26 [PATCH] net: thunderx: fix PTP device ref leak in nicvf_probe() Haoxiang Li
@ 2026-05-27  2:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-27  2:20 UTC (permalink / raw)
  To: Haoxiang Li
  Cc: sgoutham, andrew+netdev, davem, edumazet, kuba, pabeni,
	richardcochran, pombredanne, aleksey.makarov, linux-arm-kernel,
	linux-kernel, netdev, stable

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 25 May 2026 16:26:11 +0800 you wrote:
> 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.
> 
> Fixes: 4a8755096466 ("net: thunderx: add timestamping support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-27  2:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25  8:26 [PATCH] net: thunderx: fix PTP device ref leak in nicvf_probe() Haoxiang Li
2026-05-27  2:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox