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

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®