Re: [PATCH v2] mctp i3c: Fix locking in an error path

From: Matt Johnston

Date: Sun Nov 01 2026 - 23:04:29 EST


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@xxxxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: Jeremy Kerr <jk@xxxxxxxxxxxxxxxxxxxx>
> Cc: Matt Johnston <matt@xxxxxxxxxxxxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> Fixes: 2d2d4f60ed26 ("mctp i3c: fix MCTP I3C driver multi-thread issue")
> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
> ---
> 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@xxxxxxxxxxxxxxxxxxxx>