All of lore.kernel.org
 help / color / mirror / Atom feed
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 21:50:05 -0700	[thread overview]
Message-ID: <69e8537d.a00a0220.9259.0018.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(),
but i2c_mux_del_adapters() internally performs I2C transfers which
trigger rtl2832_deselect(), which reschedules i2c_gate_work via
schedule_delayed_work(). This re-arms the timer after it has been
cancelled, causing a use-after-free when kfree(dev) is called and
the timer later fires on freed memory.

Fix this by calling i2c_mux_del_adapters() before
cancel_delayed_work_sync(). Once i2c_mux_del_adapters() completes,
no further I2C transfers can go through the mux, so rtl2832_deselect()
can never re-arm the timer again, making the cancellation truly final.

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index d8e1546aea5e..9898f729304a 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -1115,10 +1115,10 @@ static void rtl2832_remove(struct i2c_client *client)
 
 	dev_dbg(&client->dev, "\n");
 
-	cancel_delayed_work_sync(&dev->i2c_gate_work);
-
 	i2c_mux_del_adapters(dev->muxc);
 
+	cancel_delayed_work_sync(&dev->i2c_gate_work);
+
 	regmap_exit(dev->regmap);
 
 	kfree(dev);
-- 
2.43.0


  reply	other threads:[~2026-04-22  4:50 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 ` syzbot [this message]
2026-04-22  5:45 ` Forwarded: [PATCH] media: rtl2832: fix use-after-free in rtl2832_remove() syzbot

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=69e8537d.a00a0220.9259.0018.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 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.