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 02/14] can: gs_usb: gs_usb_receive_bulk_callback(): check for overflow flag if SKB allocation fails
Date: Tue, 24 Nov 2026 09:30:53 +0000 [thread overview]
Message-ID: <179551265385.3131.15670583860360674202@kernel.org> (raw)
In-Reply-To: <20261122-gs_usb-fixes-v10-2-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] In gs_usb_receive_bulk_callback()
(drivers/net/can/usb/gs_usb.c), the CAN-CC RX branch now handles an…
--
can: gs_usb: gs_usb_receive_bulk_callback(): check for overflow flag if SKB allocation fails
When the RX SKB allocation fails in gs_usb_receive_bulk_callback(), this
commit increments rx_dropped. It then jumps to the overflow flag check
instead of resubmitting the URB right away. This applies to both the
CAN-FD and CAN-CC receive paths.
Closes: https://sashiko.dev/#/bug/linux-7b3fe6a0-4628-4d0e-aec0-69f4bf8ad5d4
> diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
> index d1124c49460e3..9e8567544c882 100644
> --- a/drivers/net/can/usb/gs_usb.c
> +++ b/drivers/net/can/usb/gs_usb.c
[ ... ]
> @@ -686,8 +689,11 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
> memcpy(cfd->data, hf->canfd->data, data_length);
> } else {
> skb = alloc_can_skb(netdev, &cf);
> - if (!skb)
> - goto resubmit_urb;
> + if (!skb) {
> + stats->rx_dropped++;
> +
> + goto check_overflow;
> + }
>
> cf->can_id = le32_to_cpu(hf->can_id);
> can_frame_set_cc_len(cf, hf->can_dlc, dev->can.ctrlmode);
[Severity: Medium]
Does this goto also skip the controller state update for error frames?
A few lines further down in the same CAN-CC branch of
gs_usb_receive_bulk_callback() there is:
/* ERROR frames tell us information about the controller */
if (le32_to_cpu(hf->can_id) & CAN_ERR_FLAG)
gs_update_state(dev, cf);
gs_update_state() is the only place in the RX path that sets
dev->can.state. It is also the only place that increments the can_stats
counters restarts, bus_off, error_warning and error_passive. It reads
these values from cf, so it cannot run when alloc_can_skb() fails:
gs_update_state() {
...
if (cf->can_id & CAN_ERR_RESTARTED) {
dev->can.state = CAN_STATE_ERROR_ACTIVE;
can_stats->restarts++;
} else if (cf->can_id & CAN_ERR_BUSOFF) {
dev->can.state = CAN_STATE_BUS_OFF;
can_stats->bus_off++;
...
}
Suppose the device sends a host frame with CAN_ERR_FLAG and
CAN_ERR_BUSOFF, CAN_ERR_RESTARTED or CAN_ERR_CRTL set, and the
GFP_ATOMIC allocation fails. Would dev->can.state then stay stale, for
example ERROR_ACTIVE while the controller is bus-off? Would the
can_device_stats counters reported to userspace under-count?
The old goto resubmit_urb skipped this too. However, the commit message
says the failure path "neither updates the statistics nor checks whether
an overflow flag is set", and after this change the can_stats and state
accounting are still skipped on that path.
Could the state be decoded from hf->can_id and hf->classic_can->data[1],
so it is applied even without an skb? Several other CAN drivers
(at91_can.c, mcp251xfd-core.c, rockchip_canfd-core.c, esdacc.c and
pcan_usb_fd.c) call can_change_state() with cf == NULL for this reason.
Some of them carry comments like "things must be done even in case of
OOM".
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-gs_usb-fixes-v10-0-7c165c35d04a%40pengutronix.de
next prev parent reply other threads:[~2026-11-24 9:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 18:48 [PATCH can-next v10 00/14] gs_usb: fixes Marc Kleine-Budde
2026-11-22 18:48 ` [PATCH can-next v10 01/14] can: gs_usb: gs_usb_probe(): init netdev completely before register_candev() Marc Kleine-Budde
2026-11-22 18:48 ` [PATCH can-next v10 02/14] can: gs_usb: gs_usb_receive_bulk_callback(): check for overflow flag if SKB allocation fails Marc Kleine-Budde
2026-11-24 9:30 ` netdev-bot+sashiko [this message]
2026-11-22 18:48 ` [PATCH can-next v10 03/14] can: gs_usb: gs_usb_receive_bulk_callback(): add missing call to can_rx_offload_irq_finish Marc Kleine-Budde
2026-11-22 18:48 ` [PATCH can-next v10 04/14] can: gs_usb: use spin_lock_irqsave() instead of spin_lock_bh() to protect struct gs_usb::tc Marc Kleine-Budde
2026-11-24 9:30 ` netdev-bot+sashiko
2026-11-22 18:48 ` [PATCH can-next v10 05/14] can: gs_usb: fix hardware timestamp state for mixed channels Marc Kleine-Budde
2026-11-24 9:30 ` 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=179551265385.3131.15670583860360674202@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