* 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
[not found] <20261122-gs_usb-fixes-v10-9-7c165c35d04a@pengutronix.de>
@ 2026-11-24 9:30 ` netdev-bot+sashiko
0 siblings, 0 replies; only message in thread
From: netdev-bot+sashiko @ 2026-11-24 9:30 UTC (permalink / raw)
To: mkl; +Cc: mailhol, pfink, eric, max, wg, kernel, linux-can, stable, kuba
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 9:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261122-gs_usb-fixes-v10-9-7c165c35d04a@pengutronix.de>
2026-11-24 9:30 ` [PATCH can-next v10 09/14] can: gs_usb: gs_usb_get_gs_can(): introduce new function to consolidate validation of struct gs_can netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox