mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] mctp: i3c: Fix potential thread leak on registration failure
@ 2026-11-17 14:48 Guangshuo Li
  2026-11-23 14:25 ` Paolo Abeni
  2026-11-23 14:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Guangshuo Li @ 2026-11-17 14:48 UTC (permalink / raw)
  To: Jeremy Kerr, Matt Johnston, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel

mctp_register_netdev() can fail before netdev registration begins,
leaving the TX thread and bus list entry allocated. The error path
assumes ndo_uninit has already cleaned them up.

Always clean up on registration failure. Make bus cleanup idempotent
because later registration failures can already have called ndo_uninit.

This issue was found by our static analysis tool under development.

Fixes: c8755b29b58e ("mctp i3c: MCTP I3C driver")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/net/mctp/mctp-i3c.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mctp/mctp-i3c.c b/drivers/net/mctp/mctp-i3c.c
index 5f225999d715..2d55ca88f0a8 100644
--- a/drivers/net/mctp/mctp-i3c.c
+++ b/drivers/net/mctp/mctp-i3c.c
@@ -492,7 +492,8 @@ __must_hold(&busdevs_lock)
 	}
 
 	kfree_skb(mbus->tx_skb);
-	list_del(&mbus->list);
+	mbus->tx_skb = NULL;
+	list_del_init(&mbus->list);
 }
 
 static void mctp_i3c_ndo_uninit(struct net_device *ndev)
@@ -624,7 +625,7 @@ __must_hold(&busdevs_lock)
 	rc = mctp_register_netdev(ndev, NULL, MCTP_PHYS_BINDING_I3C);
 	if (rc < 0) {
 		dev_warn(&ndev->dev, "netdev register failed: %d\n", rc);
-		goto err_free_netdev;
+		goto err_free_uninit;
 	}
 	return mbus;
 
@@ -634,7 +635,6 @@ __must_hold(&busdevs_lock)
 	 */
 	mctp_i3c_bus_free(mbus);
 
-err_free_netdev:
 	free_netdev(ndev);
 
 err:

base-commit: 2e54b3e187300893688c2c7517894f5d96732e05

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

* Re: [PATCH net] mctp: i3c: Fix potential thread leak on registration failure
  2026-11-17 14:48 [PATCH net] mctp: i3c: Fix potential thread leak on registration failure Guangshuo Li
@ 2026-11-23 14:25 ` Paolo Abeni
  2026-11-23 14:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Abeni @ 2026-11-23 14:25 UTC (permalink / raw)
  To: Guangshuo Li, Jeremy Kerr, Matt Johnston, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski
  Cc: netdev, linux-kernel

On 11/17/26 15:48, Guangshuo Li wrote:
> mctp_register_netdev() can fail before netdev registration begins,
> leaving the TX thread and bus list entry allocated. The error path
> assumes ndo_uninit has already cleaned them up.
> 
> Always clean up on registration failure. Make bus cleanup idempotent
> because later registration failures can already have called ndo_uninit.
> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: c8755b29b58e ("mctp i3c: MCTP I3C driver")
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
Issues in error paths in device init/shutdown existing since the
beginning don't qualify for 'net' target. Applying to net-next.

/P


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

* Re: [PATCH net] mctp: i3c: Fix potential thread leak on registration failure
  2026-11-17 14:48 [PATCH net] mctp: i3c: Fix potential thread leak on registration failure Guangshuo Li
  2026-11-23 14:25 ` Paolo Abeni
@ 2026-11-23 14:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-23 14:30 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: jk, matt, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 17 Nov 2026 22:48:45 +0800 you wrote:
> mctp_register_netdev() can fail before netdev registration begins,
> leaving the TX thread and bus list entry allocated. The error path
> assumes ndo_uninit has already cleaned them up.
> 
> Always clean up on registration failure. Make bus cleanup idempotent
> because later registration failures can already have called ndo_uninit.
> 
> [...]

Here is the summary with links:
  - [net] mctp: i3c: Fix potential thread leak on registration failure
    https://git.kernel.org/netdev/net-next/c/5a3f240e32b2

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] 3+ messages in thread

end of thread, other threads:[~2026-11-23 14:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 14:48 [PATCH net] mctp: i3c: Fix potential thread leak on registration failure Guangshuo Li
2026-11-23 14:25 ` Paolo Abeni
2026-11-23 14:30 ` 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

all inboxes | Powered by JetHome®