mctp: i3c: Fix potential thread leak on registration failure
PATCH 1/1 mctp: i3c: Fix potential thread leak on registration failure
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.
--- drivers/net/mctp/mctp-i3c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/mctp/mctp-i3c.c +3 -3
@@ -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
Paolo Abeni
maintainerQuoted 11 lines · Guangshuo Li
mctp_register_netdev()can fail before netdev registration begins, leaving the TX thread and bus list entry allocated. The error path assumesndo_uninithas 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 <[email protected]>
Issues in error paths in device init/shutdown existing since the beginning don't qualify for 'net' target. Applying to net-next.
/P
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · 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 assumesndo_uninithas 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html