* [PATCH v2] mctp i3c: Fix locking in an error path
@ 2026-10-29 18:00 Bart Van Assche
2026-11-02 4:03 ` Matt Johnston
2026-11-03 9:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Bart Van Assche @ 2026-10-29 18:00 UTC (permalink / raw)
To: Jeremy Kerr, Matt Johnston
Cc: Leo Yang, Paolo Abeni, netdev, linux-kernel, Bart Van Assche,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Nathan Chancellor, Leo Yang
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.
Cc: Leo Yang <Leo-Yang@quantatw.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Jeremy Kerr <jk@codeconstruct.com.au>
Cc: Matt Johnston <matt@codeconstruct.com.au>
Cc: netdev@vger.kernel.org
Fixes: 2d2d4f60ed26 ("mctp i3c: fix MCTP I3C driver multi-thread issue")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
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(-)
diff --git a/drivers/net/mctp/mctp-i3c.c b/drivers/net/mctp/mctp-i3c.c
index 4e857dd5df64..5f225999d715 100644
--- a/drivers/net/mctp/mctp-i3c.c
+++ b/drivers/net/mctp/mctp-i3c.c
@@ -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);
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] mctp i3c: Fix locking in an error path
2026-10-29 18:00 [PATCH v2] mctp i3c: Fix locking in an error path Bart Van Assche
@ 2026-11-02 4:03 ` Matt Johnston
2026-11-03 9:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Matt Johnston @ 2026-11-02 4:03 UTC (permalink / raw)
To: Bart Van Assche, Jeremy Kerr
Cc: Leo Yang, Paolo Abeni, netdev, linux-kernel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Nathan Chancellor,
Leo Yang
On Thu, 2026-10-29 at 11:00 -0700, Bart Van Assche wrote:
> 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.
>
> Cc: Leo Yang <Leo-Yang@quantatw.com>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Jeremy Kerr <jk@codeconstruct.com.au>
> Cc: Matt Johnston <matt@codeconstruct.com.au>
> Cc: netdev@vger.kernel.org
> Fixes: 2d2d4f60ed26 ("mctp i3c: fix MCTP I3C driver multi-thread issue")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> 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(-)
>
> diff --git a/drivers/net/mctp/mctp-i3c.c b/drivers/net/mctp/mctp-i3c.c
> index 4e857dd5df64..5f225999d715 100644
> --- a/drivers/net/mctp/mctp-i3c.c
> +++ b/drivers/net/mctp/mctp-i3c.c
> @@ -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.
Acked-by: Matt Johnston <matt@codeconstruct.com.au>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] mctp i3c: Fix locking in an error path
2026-10-29 18:00 [PATCH v2] mctp i3c: Fix locking in an error path Bart Van Assche
2026-11-02 4:03 ` Matt Johnston
@ 2026-11-03 9:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-03 9:10 UTC (permalink / raw)
To: Bart Van Assche
Cc: jk, matt, Leo-Yang, pabeni, netdev, linux-kernel, andrew+netdev,
davem, edumazet, kuba, nathan, leo.yang.sy0
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Thu, 29 Oct 2026 11:00:39 -0700 you wrote:
> 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.
>
> Cc: Leo Yang <Leo-Yang@quantatw.com>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Jeremy Kerr <jk@codeconstruct.com.au>
> Cc: Matt Johnston <matt@codeconstruct.com.au>
> Cc: netdev@vger.kernel.org
> Fixes: 2d2d4f60ed26 ("mctp i3c: fix MCTP I3C driver multi-thread issue")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>
> [...]
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!
--
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-03 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29 18:00 [PATCH v2] mctp i3c: Fix locking in an error path Bart Van Assche
2026-11-02 4:03 ` Matt Johnston
2026-11-03 9:10 ` 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