All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rohith Matam" <rohithmatham@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH v5] media: siano: fix URB work teardown
Date: Mon, 01 Jun 2026 16:15:19 +0000	[thread overview]
Message-ID: <20260601161519.B67951F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260601160447.59917-1-rohithmatham@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional dereference of `dev->coredev` in `smsusb_stop_streaming()` during early initialization failure paths causes a kernel panic.
--

commit d1f743fe5305e88770fc795f5d8412345cb04702
Author: Rohith Matam <rohithmatham@gmail.com>

media: siano: fix URB work teardown

This commit reinitializes URB work items before scheduling to avoid
workqueue warnings on teardown. It also fixes related lifetime bugs by
adding an abortable buffer wait and ensuring any URB submitted by an
already-running worker is completed before freeing resources.

> diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
> index 0fdc2e0950b77..565543dbd4cb1 100644
> --- a/drivers/media/usb/siano/smsusb.c
> +++ b/drivers/media/usb/siano/smsusb.c

[ ... ]

> @@ -168,20 +179,33 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
>  		smsusb_onresponse,
>  		surb
>  	);
> -	surb->urb->transfer_flags |= URB_FREE_BUFFER;
> +	rc = usb_submit_urb(surb->urb, GFP_ATOMIC);
> +	if (rc) {
> +		smscore_putbuffer(dev->coredev, surb->cb);
> +		surb->cb = NULL;
> +	}
>  
> -	return usb_submit_urb(surb->urb, GFP_ATOMIC);
> +	return rc;
>  }
>  
>  static void smsusb_stop_streaming(struct smsusb_device_t *dev)
>  {
>  	int i;
>  
> -	for (i = 0; i < MAX_URBS; i++) {
> +	WRITE_ONCE(dev->streaming, false);
> +	WRITE_ONCE(dev->stopping, true);
> +	wake_up(&dev->coredev->buffer_mng_waitq);

[Severity: High]
Can this unconditionally dereference dev->coredev when it is NULL?

If smsusb_init_device() fails its early endpoint checks, it bails out by
calling smsusb_term_device():

drivers/media/usb/siano/smsusb.c:smsusb_init_device() {
...
	if (!dev->in_ep || !dev->out_ep || align < 0) {  /* Missing endpoints? */
		smsusb_term_device(intf);
		return -ENODEV;
	}
...
}

Because smsusb_term_device() unconditionally calls smsusb_stop_streaming(),
and dev->coredev hasn't been initialized yet during this early error path,
could this new wake_up() call trigger a NULL pointer dereference?

> +
> +	for (i = 0; i < MAX_URBS; i++)
>  		usb_kill_urb(dev->surbs[i].urb);
> -		if (dev->surbs[i].wq.func)
> -			cancel_work_sync(&dev->surbs[i].wq);
>  

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260601160447.59917-1-rohithmatham@gmail.com?part=1

  reply	other threads:[~2026-06-01 16:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  6:18 [PATCH] media: usb: siano: initialize URB work once Rohith Matam
2026-06-01  6:34 ` sashiko-bot
2026-06-01 15:09 ` [PATCH v2] media: usb: siano: fix URB work teardown Rohith Matam
2026-06-01 15:21   ` sashiko-bot
2026-06-01 15:26   ` [PATCH v3] media: " Rohith Matam
2026-06-01 15:36     ` sashiko-bot
2026-06-01 15:43     ` [PATCH v4] " Rohith Matam
2026-06-01 15:55       ` sashiko-bot
2026-06-01 16:04       ` [PATCH v5] " Rohith Matam
2026-06-01 16:15         ` sashiko-bot [this message]
2026-06-01 20:16         ` [PATCH v6] " Rohith Matam

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=20260601161519.B67951F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=rohithmatham@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.