From: syzbot <syzbot+019ced393ab913002b75@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] media: rtl2832: fix use-after-free in rtl2832_remove()
Date: Tue, 21 Apr 2026 22:45:51 -0700 [thread overview]
Message-ID: <69e8608f.a00a0220.17a17.0027.GAE@google.com> (raw)
In-Reply-To: <69e69c55.050a0220.24bfd3.0029.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] media: rtl2832: fix use-after-free in rtl2832_remove()
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
cancel_delayed_work_sync() is called before i2c_mux_del_adapters()
in rtl2832_remove(). If i2c_mux_del_adapters() triggers any I2C
transfers through the mux adapter, rtl2832_deselect() will be called
which reschedules i2c_gate_work via schedule_delayed_work(). This
re-arms the timer after it was cancelled, causing a use-after-free
when kfree(dev) is called and the timer later fires on freed memory.
Fix this by moving cancel_delayed_work_sync() to after
i2c_mux_del_adapters(), ensuring the cancellation is the last
operation before kfree(dev).
Reported-by: syzbot+019ced393ab913002b75@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=019ced393ab913002b75
Signed-off-by: Deepanshu Kartikey <Kartikey406@gmail.com>
---
drivers/media/dvb-frontends/rtl2832.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index d8e1546aea5e..ce3326feaa7d 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -821,6 +821,9 @@ static int rtl2832_deselect(struct i2c_mux_core *muxc, u32 chan_id)
{
struct rtl2832_dev *dev = i2c_mux_priv(muxc);
+ pr_err("rtl2832_deselect called from: %pS\n",
+ __builtin_return_address(0));
+
schedule_delayed_work(&dev->i2c_gate_work, usecs_to_jiffies(100));
return 0;
}
@@ -1113,12 +1116,18 @@ static void rtl2832_remove(struct i2c_client *client)
{
struct rtl2832_dev *dev = i2c_get_clientdata(client);
+ pr_err("rtl2832_remove: before cancel\n");
+
dev_dbg(&client->dev, "\n");
cancel_delayed_work_sync(&dev->i2c_gate_work);
+ pr_err("rtl2832_remove: before i2c_mux_del_adapters\n");
+
i2c_mux_del_adapters(dev->muxc);
+ pr_err("rtl2832_remove: before kfree\n");
+
regmap_exit(dev->regmap);
kfree(dev);
--
2.43.0
prev parent reply other threads:[~2026-04-22 5:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 21:36 [syzbot] [i2c?] [usb?] WARNING: ODEBUG bug in i2c_device_remove (2) syzbot
2026-04-22 4:50 ` Forwarded: [PATCH] media: rtl2832: fix use-after-free in rtl2832_remove() syzbot
2026-04-22 5:45 ` 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=69e8608f.a00a0220.17a17.0027.GAE@google.com \
--to=syzbot+019ced393ab913002b75@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox