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, shuangpeng.kernel@gmail.com,
stable@vger.kernel.org, vadim.fedorenko@linux.dev,
kuba@kernel.org
Subject: Re: [PATCH can-next v9 09/13] can: gs_usb: gs_usb_get_gs_can(): introduce new function to consolidate validation of struct gs_can
Date: Mon, 23 Nov 2026 12:00:27 +0000 [thread overview]
Message-ID: <179543522703.3131.14984060742934777672@kernel.org> (raw)
In-Reply-To: <20261121-gs_usb-fixes-v9-9-db121d488945@pengutronix.de>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message presents this patch as a pure refactor ("To
improve code readability and structure consolidate the decoding and…
--
can: gs_usb: gs_usb_get_gs_can(): introduce new function to consolidate validation of struct gs_can
This patch adds a new helper, gs_usb_get_gs_can(). It takes over three
checks from gs_usb_receive_bulk_callback(): the short read check on the
RX header, the channel id range check, and the netdev present/running
checks.
The helper returns the struct gs_can pointer or NULL. It also sets a
fatal flag, which the caller uses to decide 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 f49179cbd7876..c392cf65d8a6d 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: Low]
Is this change in behavior intended? The commit message presents the
patch as a refactor:
To improve code readability and structure consolidate the decoding and
validation of the struct gs_can from the host frame into a the new
function gs_usb_get_gs_can().
However, the not-present case now behaves differently. Before the patch,
gs_usb_receive_bulk_callback() returned without resubmitting the URB and
did not touch the other channels:
if (!netif_device_present(netdev))
return;
Now that *fatal is set here, the caller jumps to device_detach, which
detaches every channel of the parent:
device_detach:
for (rc = 0; rc < parent->channel_cnt; rc++) {
if (parent->canch[rc])
netif_device_detach(parent->canch[rc]->netdev);
}
One channel can be detached by itself. For example, gs_can_start_xmit()
and gs_can_open() call netif_device_detach() on only their own netdev
when they get -ENODEV. Before this patch the sibling channels stayed
attached in that case. With this patch, the next RX frame carrying the
detached channel's index also detaches all the siblings.
This is probably harmless in practice. -ENODEV means the shared USB
device is gone, so the siblings would fail anyway, and in both versions
the URB is not resubmitted.
The commit message does say "If fatal is true, detach the device", but
it doesn't mention that the not-present case used to be handled
differently. This behavior is still the same later in the series:
gs_usb_get_gs_can() still sets *fatal for !netif_device_present() in
"can: gs_usb: gs_usb_host_frame_header_valid(): drop CAN frames with
invalid DLC".
Could the commit message mention and justify this change? Otherwise,
should the old behavior (neither resubmit nor detach) be kept for this
case?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121-gs_usb-fixes-v9-0-db121d488945%40pengutronix.de
next prev parent reply other threads:[~2026-11-23 12:00 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 22:35 [PATCH can-next v9 00/13] gs_usb: fixes Marc Kleine-Budde
2026-11-21 22:35 ` [PATCH can-next v9 01/13] can: gs_usb: gs_usb_probe(): init netdev completely before register_candev() Marc Kleine-Budde
2026-11-21 22:36 ` [PATCH can-next v9 02/13] can: gs_usb: gs_usb_receive_bulk_callback(): check for overflow flag if SKB allocation fails Marc Kleine-Budde
2026-11-21 22:36 ` [PATCH can-next v9 03/13] can: gs_usb: gs_usb_receive_bulk_callback(): add missing call to can_rx_offload_irq_finish Marc Kleine-Budde
2026-11-21 22:36 ` [PATCH can-next v9 04/13] can: gs_usb: use spin_lock_irqsave() instead of spin_lock_bh() to protect struct gs_usb::tc Marc Kleine-Budde
2026-11-21 22:36 ` [PATCH can-next v9 05/13] can: gs_usb: fix hardware timestamp state for mixed channels Marc Kleine-Budde
2026-11-21 22:43 ` sashiko-bot
2026-11-23 12:00 ` netdev-bot+sashiko
2026-11-21 22:36 ` [PATCH can-next v9 06/13] can: gs_usb: add support for context analysis Marc Kleine-Budde
2026-11-21 22:42 ` sashiko-bot
2026-11-23 12:00 ` netdev-bot+sashiko
2026-11-21 22:36 ` [PATCH can-next v9 07/13] can: gs_usb: gs_make_candev(): check can_rx_offload_add_manual() return value Marc Kleine-Budde
2026-11-21 22:36 ` [PATCH can-next v9 08/13] can: gs_usb: gs_usb_receive_bulk_callback(): use dev_info() to print re-submit info messages Marc Kleine-Budde
2026-11-21 22:42 ` sashiko-bot
2026-11-23 12:00 ` netdev-bot+sashiko
2026-11-21 22:36 ` [PATCH can-next v9 09/13] can: gs_usb: gs_usb_get_gs_can(): introduce new function to consolidate validation of struct gs_can Marc Kleine-Budde
2026-11-23 12:00 ` netdev-bot+sashiko [this message]
2026-11-21 22:36 ` [PATCH can-next v9 10/13] can: gs_usb: gs_usb_get_gs_can(): report channel number out of range error Marc Kleine-Budde
2026-11-23 12:00 ` netdev-bot+sashiko
2026-11-21 22:36 ` [PATCH can-next v9 11/13] can: gs_usb: gs_usb_get_rx_data_length(): introduce new function to consolidate validation of host frame Marc Kleine-Budde
2026-11-23 12:00 ` netdev-bot+sashiko
2026-11-21 22:36 ` [PATCH can-next v9 12/13] can: gs_usb: gs_usb_host_frame_header_valid(): drop invalid CAN error frames Marc Kleine-Budde
2026-11-21 22:53 ` sashiko-bot
2026-11-21 23:02 ` Marc Kleine-Budde
2026-11-23 7:41 ` Marc Kleine-Budde
2026-11-23 12:00 ` netdev-bot+sashiko
2026-11-21 22:36 ` [PATCH can-next v9 13/13] can: gs_usb: gs_usb_host_frame_header_valid(): drop CAN frames with invalid DLC Marc Kleine-Budde
2026-11-23 12:00 ` netdev-bot+sashiko
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=179543522703.3131.14984060742934777672@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=shuangpeng.kernel@gmail.com \
--cc=stable@vger.kernel.org \
--cc=vadim.fedorenko@linux.dev \
--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