From: Jakub Kicinski <kuba@kernel.org>
To: mkl@pengutronix.de
Cc: Jakub Kicinski <kuba@kernel.org>,
stable@vger.kernel.org, kernel@pengutronix.de,
socketcan@hartkopp.net, davem@davemloft.net,
linux-can@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [net,2/7] can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error
Date: Mon, 19 Jan 2026 10:19:03 -0800 [thread overview]
Message-ID: <20260119181904.1209979-1-kuba@kernel.org> (raw)
In-Reply-To: <20260116200323.366877-3-mkl@pengutronix.de>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error
This patch fixes an infinite loop in gs_can_close() by unanchoring the URB
when usb_submit_urb() fails after re-anchoring. It also adds an error
message for non-ENODEV/ESHUTDOWN failures.
Link: https://patch.msgid.link/20260116-can_usb-fix-reanchor-v1-1-9d74e7289225@pengutronix.de
> diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
> index d093babbc320..192338b481f2 100644
> --- a/drivers/net/can/usb/gs_usb.c
> +++ b/drivers/net/can/usb/gs_usb.c
> @@ -754,6 +754,10 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
> usb_anchor_urb(urb, &parent->rx_submitted);
>
> rc = usb_submit_urb(urb, GFP_ATOMIC);
> + if (!rc)
> + return;
> +
> + usb_unanchor_urb(urb);
>
> /* USB failure take down all interfaces */
> if (rc == -ENODEV) {
[ ... ]
> + } else if (rc != -ESHUTDOWN && net_ratelimit()) {
> + netdev_info(netdev, "failed to re-submit IN URB: %pe\n",
> + ERR_PTR(urb->status));
Two issues with this error message:
1. The message prints urb->status, but shouldn't it print rc instead? The
variable rc holds the actual error from usb_submit_urb(), while urb->status
contains the completion status from the previous callback invocation (which
would typically be 0 for success since we only reach resubmit_urb on
successful URB completion). Other CAN USB drivers like usb_8dev print the
return value from usb_submit_urb() in similar error paths.
2. The local variable netdev is uninitialized when gs_usb_receive_bulk_callback()
reaches this code path via the short read case. The function declares netdev
at the top without initialization, and the short read check at the beginning
of the function jumps directly to resubmit_urb without ever assigning netdev.
If usb_submit_urb() then fails with an error other than -ENODEV or -ESHUTDOWN,
this code will pass the uninitialized netdev pointer to netdev_info().
> }
> }
next prev parent reply other threads:[~2026-01-19 18:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 19:55 [PATCH net 0/7] pull-request: can 2026-01-16 Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 1/7] can: dev: alloc_candev_mqs(): add missing default CAN capabilities Marc Kleine-Budde
2026-01-19 18:30 ` patchwork-bot+netdevbpf
2026-01-16 19:55 ` [PATCH net 2/7] can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error Marc Kleine-Budde
2026-01-19 18:19 ` Jakub Kicinski [this message]
2026-01-23 17:36 ` [net,2/7] " Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 3/7] can: ems_usb: ems_usb_read_bulk_callback(): fix URB memory leak Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 4/7] can: esd_usb: esd_usb_read_bulk_callback(): " Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 5/7] can: kvaser_usb: kvaser_usb_read_bulk_callback(): " Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 6/7] can: mcba_usb: mcba_usb_read_bulk_callback(): " Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 7/7] can: usb_8dev: usb_8dev_read_bulk_callback(): " Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260119181904.1209979-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=socketcan@hartkopp.net \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox