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 moves register_candev() out of gs_make_candev() into a second loop in gs_usb_probe(). -- can: gs_usb: gs_usb_probe(): init netdev completely before register_candev() This patch takes register_candev() out of gs_make_candev(). The probe routine now allocates and fully initializes every CAN channel first, then registers them all in a second loop. unregister_candev() moves out of gs_destroy_candev() into gs_usb_disconnect() and the probe error paths. Link: https://patch.msgid.link/2026…@pengutronix.de
> diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c > index 15f28833f2deb..965151ab50a1e 100644 > --- a/drivers/net/can/usb/gs_usb.c > +++ b/drivers/net/can/usb/gs_usb.c
[ ... ]
> @@ -1621,7 +1605,37 @@ static int gs_usb_probe(struct usb_interface *intf, > parent->hf_size_rx = max(parent->hf_size_rx, hf_size_rx); > } > > + for (i = 0; i < icount; i++) { > + struct gs_can *dev = parent->canch[i]; > + > + rc = register_candev(dev->netdev);
[Severity: Medium] With this ordering, every parent->canch[i] is non-NULL before any channel is registered. Once register_candev() returns for channel 0, userspace can open can0 while canch[1..n] are still unregistered. Opening the first channel submits all of the shared bulk-IN URBs: gs_can_open() { ... if (!parent->active_channels) { ... for (i = 0; i < GS_MAX_RX_URBS; i++) { ... } Suppose the device sends a frame for a channel that is not registered yet, inside this window. What happens in gs_usb_receive_bulk_callback()? dev = parent->canch[hf->channel]; netdev = dev->netdev; stats = &netdev->stats; if (!netif_device_present(netdev)) return; Only register_netdevice() sets __LINK_STATE_PRESENT, so the unregistered netdev looks detached. The bare return skips the resubmit_urb label. USB core has already unanchored the URB, so it is never resubmitted. Could each such frame permanently remove one URB from the shared RX pool? If enough of them arrive, would reception stop on all channels until every channel is closed and reopened? The window covers the rest of gs_can_open(), including its control transfers, which run under RTNL. register_candev() for the next channel also has to wait for RTNL. Triggering this needs a device that sends frames for a channel the host has not started. One example is firmware that keeps channel state across re-enumeration, because probe does not reset the channels. Before this patch the same input would dereference a NULL canch[1], so this is an improvement. However, the RX path now treats the new "allocated but not yet registered" state as a detached device. The early return in gs_usb_receive_bulk_callback() is still unchanged at the end of the series (6f2e6f8d658b).
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40pengutronix.de