From: syzbot <syzbot+537b5eb78cebbff5ea70@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] media: gspca: don't call stopN/stop0 after device disconnect
Date: Sun, 30 Aug 2026 01:16:32 -0700 [thread overview]
Message-ID: <6a93e6e0.1d9ded08.62e62.0119.GAE@google.com> (raw)
In-Reply-To: <6a9087a4.4d659fcc.734b4.0014.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] media: gspca: don't call stopN/stop0 after device disconnect
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
gspca_stream_off() calls the sub-driver's stopN() and stop0()
callbacks unconditionally. These issue USB requests using
gspca_dev->dev, which becomes a dangling pointer once the USB device
has been disconnected and freed, causing a use-after-free when the
video device fd is closed after disconnect.
Add a gspca_dev->present check before calling stopN() and stop0(),
matching the existing check already used for gspca_input_create_urb()
in the same function.
Reported-by: syzbot+537b5eb78cebbff5ea70@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=537b5eb78cebbff5ea70
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
drivers/media/usb/gspca/gspca.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 594d73e50b9f..5c33cf397f3d 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -733,14 +733,14 @@ static void gspca_stream_off(struct gspca_dev *gspca_dev)
{
gspca_dev->streaming = false;
gspca_dev->usb_err = 0;
- if (gspca_dev->sd_desc->stopN)
+ if (gspca_dev->present && gspca_dev->sd_desc->stopN)
gspca_dev->sd_desc->stopN(gspca_dev);
destroy_urbs(gspca_dev);
gspca_input_destroy_urb(gspca_dev);
gspca_set_alt0(gspca_dev);
if (gspca_dev->present)
gspca_input_create_urb(gspca_dev);
- if (gspca_dev->sd_desc->stop0)
+ if (gspca_dev->present && gspca_dev->sd_desc->stop0)
gspca_dev->sd_desc->stop0(gspca_dev);
gspca_dbg(gspca_dev, D_STREAM, "stream off OK\n");
}
--
2.43.0
prev parent reply other threads:[~2026-08-30 8:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 18:53 [syzbot] [media?] [usb?] KASAN: slab-use-after-free Read in sd_stopN syzbot
2026-08-30 8:16 ` syzbot [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=6a93e6e0.1d9ded08.62e62.0119.GAE@google.com \
--to=syzbot+537b5eb78cebbff5ea70@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.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 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.