public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
	netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	linux-can@vger.kernel.org, kernel@pengutronix.de,
	"Ji-Ze Hong (Peter Hong)" <peter_hong@fintek.com.tw>,
	Vincent Mailhol <mailhol@kernel.org>,
	stable@kernel.org
Subject: Re: [PATCH net 08/12] can: usb: f81604: handle short interrupt urb messages properly
Date: Wed, 4 Mar 2026 10:07:37 +0100	[thread overview]
Message-ID: <2026030421-playoff-unashamed-593d@gregkh> (raw)
In-Reply-To: <790d9b0e-cc3f-44e4-9ddc-b7f2ac3a3f8a@redhat.com>

On Tue, Mar 03, 2026 at 03:23:19PM +0100, Paolo Abeni wrote:
> On 3/2/26 4:16 PM, Marc Kleine-Budde wrote:
> > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > 
> > If an interrupt urb is received that is not the correct length, properly
> > detect it and don't attempt to treat the data as valid.
> > 
> > Cc: Ji-Ze Hong (Peter Hong) <peter_hong@fintek.com.tw>
> > Cc: Marc Kleine-Budde <mkl@pengutronix.de>
> > Cc: Vincent Mailhol <mailhol@kernel.org>
> > Cc: stable@kernel.org
> > Assisted-by: gkh_clanker_2000
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Link: https://patch.msgid.link/2026022331-opal-evaluator-a928@gregkh
> > Fixes: 88da17436973 ("can: usb: f81604: add Fintek F81604 support")
> > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> > ---
> >  drivers/net/can/usb/f81604.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/net/can/usb/f81604.c b/drivers/net/can/usb/f81604.c
> > index 76578063ac82..c61bd30d1765 100644
> > --- a/drivers/net/can/usb/f81604.c
> > +++ b/drivers/net/can/usb/f81604.c
> > @@ -620,6 +620,12 @@ static void f81604_read_int_callback(struct urb *urb)
> >  		netdev_info(netdev, "%s: Int URB aborted: %pe\n", __func__,
> >  			    ERR_PTR(urb->status));
> >  
> > +	if (urb->actual_length < sizeof(*data)) {
> > +		netdev_warn(netdev, "%s: short int URB: %u < %zu\n",
> > +			    __func__, urb->actual_length, sizeof(*data));
> > +		goto resubmit_urb;
> > +	}
> > +
> >  	switch (urb->status) {
> >  	case 0: /* success */
> >  		break;
> 
> AI says:
> 
> ---
> Should the length check happen after the status check instead of before it?
> With the current ordering, if a URB completes with both a terminal error
> status (like -ESHUTDOWN, -ENOENT, -EPIPE, or -EPROTO) and insufficient
> data length, the code will jump to resubmit_urb instead of returning
> immediately.
> 
> Looking at the switch statement that follows:
> 
> >  	switch (urb->status) {
> >  	case 0: /* success */
> >  		break;
> >
> > 	case -ENOENT:
> > 	case -EPIPE:
> > 	case -EPROTO:
> > 	case -ESHUTDOWN:
> > 		return;
> 
> Terminal error codes should cause immediate return without resubmission,
> but the length check bypasses this. This could lead to inappropriate URB
> resubmissions when the device is shutting down or has been disconnected.
> ---
> 
> IDK if 'status' is valid in case of short URB, possibly the patch code
> is fine, but please have a look. Again, not blocking the PR.

status will be valid in case of a short URB, so all should be fine.

thanks,

greg k-h

  reply	other threads:[~2026-03-04  9:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 15:16 [PATCH net 0/12] pull-request: can 2026-03-02 Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 01/12] can: bcm: fix locking for bcm_op runtime updates Marc Kleine-Budde
2026-03-05  1:00   ` patchwork-bot+netdevbpf
2026-03-02 15:16 ` [PATCH net 02/12] can: dummy_can: dummy_can_init(): fix packet statistics Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 03/12] can: mcp251x: fix deadlock in error path of mcp251x_open Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 04/12] can: esd_usb: add endpoint type validation Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 05/12] can: ems_usb: ems_usb_read_bulk_callback(): check the proper length of a message Marc Kleine-Budde
2026-03-03 14:20   ` Paolo Abeni
2026-03-03 14:33     ` Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 06/12] can: ucan: Fix infinite loop from zero-length messages Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 07/12] can: usb: etas_es58x: correctly anchor the urb in the read bulk callback Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 08/12] can: usb: f81604: handle short interrupt urb messages properly Marc Kleine-Budde
2026-03-03 14:23   ` Paolo Abeni
2026-03-04  9:07     ` Greg Kroah-Hartman [this message]
2026-03-02 15:16 ` [PATCH net 09/12] can: usb: f81604: handle bulk write errors properly Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 10/12] can: usb: f81604: correctly anchor the urb in the read bulk callback Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 11/12] can: gs_usb: gs_can_open(): always configure bitrates before starting device Marc Kleine-Budde
2026-03-02 15:16 ` [PATCH net 12/12] dt-bindings: net: can: nxp,sja1000: add reference to mc-peripheral-props.yaml Marc Kleine-Budde

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=2026030421-playoff-unashamed-593d@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peter_hong@fintek.com.tw \
    --cc=stable@kernel.org \
    /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