mctp i3c: Fix locking in an error path
PATCH v2 1/1 mctp i3c: Fix locking in an error path
If netdev_alloc_skb() fails, mctp_i3c_read() jumps to a label that unlocks mi->lock although that mutex has not been locked yet. Fix this by returning -ENOMEM directly. This bug has been detected by the Clang thread-safety analyzer.
---
v1 -> v2:
- Return -ENOMEM directly upon allocation failure instead of adding a free_skb label.
drivers/net/mctp/mctp-i3c.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/mctp/mctp-i3c.c +1 -2
@@ -111,8 +111,7 @@ static int mctp_i3c_read(struct mctp_i3c_device *mi) mi->mrl + sizeof(struct mctp_i3c_internal_hdr));if (!skb) { stats->rx_dropped++; - rc = -ENOMEM ; - goto err; +return -ENOMEM ; } skb->protocol =htons (ETH_P_MCTP );
Quoted 25 lines · Bart Van Assche
If
netdev_alloc_skb()fails,mctp_i3c_read()jumps to a label that unlocksmi->lockalthough that mutex has not been locked yet. Fix this by returning-ENOMEMdirectly. This bug has been detected by the Clang thread-safety analyzer.Cc Leo Yang <[email protected]>Cc Paolo Abeni <[email protected]>Cc Jeremy Kerr <[email protected]>Cc Matt Johnston <[email protected]>Fixes 2d2d4f60ed26 ("mctp i3c: fix MCTP I3C driver multi-thread issue")Signed-off-by Bart Van Assche <[email protected]>---
v1 -> v2:
- Return-ENOMEMdirectly upon allocation failure instead of adding afree_skblabel.drivers/net/mctp/mctp-i3c.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/mctp/mctp-i3c.c +0
-0
drivers/net/mctp/mctp-i3c.c static int mctp_i3c_read(struct mctp_i3c_device *mi) · line 115
Quoted 7 lines
drivers/net/mctp/mctp-i3c.c +1
-2@@ -111,8 +111,7 @@ static int mctp_i3c_read(struct mctp_i3c_device *mi) mi->mrl + sizeof(struct mctp_i3c_internal_hdr));if (!skb) { stats->rx_dropped++; - rc = -ENOMEM ; - goto err; +return -ENOMEM ; }
Thank you.
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 13 lines · On Thu, 29 Oct 2026 11:00:39 -0700 you wrote:
If
netdev_alloc_skb()fails,mctp_i3c_read()jumps to a label that unlocksmi->lockalthough that mutex has not been locked yet. Fix this by returning-ENOMEMdirectly. This bug has been detected by the Clang thread-safety analyzer.Cc Leo Yang <[email protected]>Cc Paolo Abeni <[email protected]>Cc Jeremy Kerr <[email protected]>Cc Matt Johnston <[email protected]>Fixes 2d2d4f60ed26 ("mctp i3c: fix MCTP I3C driver multi-thread issue")Signed-off-by Bart Van Assche <[email protected]>
Quoted 1 line
[...]
Here is the summary with links:
- [v2] mctp i3c: Fix locking in an error path
https://git.kernel.org/netdev/net/c/750eb5ab457e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html