From: netdev-bot+sashiko@kernel.org
To: mkl@pengutronix.de
Cc: mailhol@kernel.org, pfink@christ-es.de, eric@evenchick.com,
max@schneidersoft.net, wg@grandegger.com, kernel@pengutronix.de,
linux-can@vger.kernel.org, stable@vger.kernel.org,
kuba@kernel.org
Subject: Re: [PATCH can-next v10 09/14] can: gs_usb: gs_usb_get_gs_can(): introduce new function to consolidate validation of struct gs_can
Date: Tue, 24 Nov 2026 09:30:59 +0000 [thread overview]
Message-ID: <179551265988.3131.9960814686983174068@kernel.org> (raw)
In-Reply-To: <20261122-gs_usb-fixes-v10-9-7c165c35d04a@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] This patch quietly changes how gs_usb_receive_bulk_callback()
handles a frame for a channel whose netdev is not present.
--
can: gs_usb: gs_usb_get_gs_can(): introduce new function to consolidate validation of struct gs_can
This commit moves the decoding and validation of struct gs_can from the
host frame header into a new helper, gs_usb_get_gs_can(). The helper
returns the gs_can pointer on success, or NULL on error. A fatal flag
tells the caller whether to detach the device or resubmit the URB.
> diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
> index 75adec495e657..9078460aebcaa 100644
> --- a/drivers/net/can/usb/gs_usb.c
> +++ b/drivers/net/can/usb/gs_usb.c
[ ... ]
> @@ -651,6 +651,43 @@ gs_usb_get_minimum_rx_length(const struct gs_can *dev, const struct gs_host_fram
> return minimum_length;
> }
>
> +static struct gs_can *
> +gs_usb_get_gs_can(const struct gs_usb *parent,
> + const struct gs_host_frame_header *header, u32 actual_length,
> + bool *fatal)
> +{
[ ... ]
> + struct gs_can *dev = parent->canch[header->channel];
> + const struct net_device *netdev = dev->netdev;
> +
> + if (!netif_device_present(netdev)) {
> + *fatal = true;
> +
> + return NULL;
> + }
[Severity: Medium]
Is this a deliberate behaviour change? Before this patch, the
!netif_device_present() case did a plain return in
gs_usb_receive_bulk_callback(). It dropped that one URB without
resubmitting it, and it left the other channels alone:
- if (!netif_device_present(netdev))
- return;
With *fatal = true, the caller now jumps to device_detach. That label
detaches every channel on the adapter:
device_detach:
for (rc = 0; rc < parent->channel_cnt; rc++) {
if (parent->canch[rc])
netif_device_detach(parent->canch[rc]->netdev);
}
A netdev can be not-present while the USB device is still attached.
gs_usb_probe() fills parent->canch[] for all channels first. It then
calls register_candev() one channel at a time:
for (i = 0; i < icount; i++) {
struct gs_can *dev = parent->canch[i];
rc = register_candev(dev->netdev);
So channel 0 can be opened before channel 1 is registered, and
gs_can_open() submits the shared bulk-IN URBs. If the device then sends
a frame tagged with the unregistered channel, would that now detach the
running channel 0 as well?
Once channel 0 is detached, its later RX frames also hit the fatal
path and the URBs are never resubmitted. TX queues stop, and reopening
fails with -ENODEV. gs_usb.c never calls netif_device_attach(), so the
channels appear to stay detached until the device is re-probed.
The other detach sites in this file only detach the affected channel's
netdev on -ENODEV, for example in gs_can_start_xmit():
if (rc == -ENODEV) {
netif_device_detach(netdev);
A single bool also can't express the old third outcome: drop the URB,
don't resubmit, don't detach.
The commit message says:
If fatal is
true, detach the device, otherwise re-submit the URB.
It doesn't mention that a case which used to just drop the URB now
detaches every channel. If this change is intended, could the commit
message say so? Otherwise, could the old drop-only behaviour be kept for
the not-present case?
This behaviour looks the same at the end of the series. The final
gs_usb_get_gs_can() still sets *fatal for !netif_device_present(), and
probe still registers the channels in sequence.
> +
> + if (!netif_running(netdev))
> + return NULL;
> +
> + return dev;
> +}
[ ... ]
> @@ -678,30 +716,17 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
> return;
> }
>
> - minimum_length = sizeof(hf->header);
> - if (urb->actual_length < minimum_length) {
> - dev_err_ratelimited(&parent->udev->dev,
> - "short read (actual_length=%u, minimum_length=%u)\n",
> - urb->actual_length, minimum_length);
> + dev = gs_usb_get_gs_can(parent, &hf->header, urb->actual_length, &fatal);
> + if (!dev) {
> + if (fatal)
> + goto device_detach;
>
> goto resubmit_urb;
> }
>
> - /* device reports out of range channel id */
> - if (hf->channel >= parent->channel_cnt)
> - goto device_detach;
> -
> - dev = parent->canch[hf->channel];
> -
> netdev = dev->netdev;
> stats = &netdev->stats;
>
> - if (!netif_device_present(netdev))
> - return;
> -
> - if (!netif_running(netdev))
> - goto resubmit_urb;
> -
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-gs_usb-fixes-v10-0-7c165c35d04a%40pengutronix.de
parent reply other threads:[~2026-11-24 9:31 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20261122-gs_usb-fixes-v10-9-7c165c35d04a@pengutronix.de>]
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=179551265988.3131.9960814686983174068@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=eric@evenchick.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=max@schneidersoft.net \
--cc=mkl@pengutronix.de \
--cc=pfink@christ-es.de \
--cc=stable@vger.kernel.org \
--cc=wg@grandegger.com \
/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