All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Joel Peech" <linux@jrpmail.ca>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH] media: usb: as102: initialize mutexes before registration
Date: Tue, 02 Jun 2026 16:08:13 +0000	[thread overview]
Message-ID: <20260602160813.B29621F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602155529.4097328-1-linux@jrpmail.ca>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] If `as102_start_stream()` fails, `as102_dev->streaming` is left incremented, permanently breaking the hardware streaming state.
--

commit 2c8befce227c56474dec3c665bf27984a30ca17a
Author: Joel Peech <linux@jrpmail.ca>

media: usb: as102: initialize mutexes before registration

This commit moves the initialization of bus_adap.lock and as102_dev->sem
to occur before registering DVB demux and frontend objects. This prevents
callbacks from using these mutexes before they are initialized, resolving
a lockdep warning.

Reported-by: syzbot+3825a6102073c418fe41@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3825a6102073c418fe41
Link: https://lore.kernel.org/r/tencent_F063E97E23B8C4431762377E26CC336AE305@qq.com

> diff --git a/drivers/media/usb/as102/as102_drv.c b/drivers/media/usb/as102/as102_drv.c
> index 6b1d3528a0a7f..60827acd73f87 100644
> --- a/drivers/media/usb/as102/as102_drv.c
> +++ b/drivers/media/usb/as102/as102_drv.c
> @@ -296,6 +296,12 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
>  		return ret;
>  	}
>  
> +	/* init bus mutex for token locking */
> +	mutex_init(&as102_dev->bus_adap.lock);
> +
> +	/* init start / stop stream mutex */
> +	mutex_init(&as102_dev->sem);
> +
>  	as102_dev->dvb_dmx.priv = as102_dev;
>  	as102_dev->dvb_dmx.filternum = pid_filtering ? 16 : 256;

[ ... ]

[Severity: High]
This is a pre-existing issue, but does this error handling leave the hardware
stream state permanently desynchronized?

Looking at as102_dvb_dmx_start_feed() which takes this newly initialized
mutex, the streaming counter is incremented unconditionally before attempting
to start the stream:

drivers/media/usb/as102/as102_drv.c:as102_dvb_dmx_start_feed() {
        ...
        if (as102_dev->streaming++ == 0)
                ret = as102_start_stream(as102_dev);

        mutex_unlock(&as102_dev->sem);
        return ret;
}

If as102_start_stream() fails, it returns an error directly while leaving
the streaming counter incremented.

The DVB core handles the feed creation failure by aborting, which means it
will not call stop_feed() during cleanup. Because the streaming counter
remains greater than zero, subsequent calls to start a feed will skip
as102_start_stream() entirely.

Does this counter need to be decremented when as102_start_stream() returns
an error to ensure the device can recover from stream start failures?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260602155529.4097328-1-linux@jrpmail.ca?part=1

      reply	other threads:[~2026-06-02 16:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26  5:13 [syzbot] [media?] INFO: trying to register non-static key in as102_dvb_dmx_start_feed syzbot
2026-03-26  9:29 ` Edward Adam Davis
2026-03-26 10:12   ` syzbot
2026-03-26 11:13 ` Edward Adam Davis
2026-03-26 11:44   ` syzbot
2026-03-26 12:15 ` Edward Adam Davis
2026-03-26 12:40   ` syzbot
2026-03-26 12:45 ` Edward Adam Davis
2026-03-26 13:12   ` syzbot
2026-03-26 13:17 ` [PATCH] media: usb: as102: fix race condition between ioctl and register Edward Adam Davis
2026-06-02 15:55   ` [PATCH] media: usb: as102: initialize mutexes before registration Joel Peech
2026-06-02 16:08     ` sashiko-bot [this message]

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=20260602160813.B29621F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@jrpmail.ca \
    --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.