From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE28B391836; Thu, 30 Jul 2026 15:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785424524; cv=none; b=d30+ltG3lfEPTICxPFspAcPzdbc3rH0dUPzEtMTEK1RHJ5AvUE/5EeUmaFOssqGU+6RvWMDdbYd/xQYTjiW+OqH3Fe0ARIpnsQPD5AuN5AcFPZvYC1mYS3UrX3spgygKXbys1Cpo2wq8IoHX1zTTZoztKX3MdpnZkEHYulvpNog= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785424524; c=relaxed/simple; bh=zjuAi3YTTYv9SI4/iRvmlnkClr/ZcL7wpbUcFnH+DO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H/qI/MG6zEdxBz9U2LfLMK2OYRml1sSpWOwGI3i+82o/piKIT5zeCQd9Ef/xPg8XRKrcr7piFaOfbO2GRZqKJKNXCXM9o1OgtLBaqW4Qk++BxVJqpTcHlUpSmXSwKYvM2SqCGSfMRVuaewBZtOAlsnfEqOe9bTNO4JqLmxo5oVc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=coZ5LY0R; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="coZ5LY0R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19B021F000E9; Thu, 30 Jul 2026 15:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785424523; bh=YtDadOqhZj8tL8tidhmLv9cB25I4g6Fva/1J6dF1j0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=coZ5LY0RUH7ihedck06TijU0d9RQFYyEvx8lpsYiJYgx4kRrMKgPxSoW0bM1iRnG1 pgZVVJD7qU7X0oyaQL/yLdedNcM4k9jjfJOduspDfdMpMKyqZW5+a2gGeZIrvIoGmo btnxpFkqFVbcq8KZqLy+yDGkA/l6c6ieUBvzDjP8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+019ced393ab913002b75@syzkaller.appspotmail.com, Deepanshu Kartikey , Hans Verkuil Subject: [PATCH 6.18 425/675] media: rtl2832: fix use-after-free in rtl2832_remove() Date: Thu, 30 Jul 2026 16:12:35 +0200 Message-ID: <20260730141454.167749190@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141445.110192266@linuxfoundation.org> References: <20260730141445.110192266@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Deepanshu Kartikey commit 680daf40a82d483949f87f0d8f98639dc47e610c upstream. cancel_delayed_work_sync() is called before i2c_mux_del_adapters() in rtl2832_remove(). While the cancel waits for any running instance of i2c_gate_work to finish, it does not prevent the timer from being rescheduled by a concurrent thread. During probe, the r820t_attach() call attempts I2C transfers through the mux adapter. These transfers go through i2c_mux_master_xfer(), which calls rtl2832_deselect() after the transfer completes, rescheduling i2c_gate_work via schedule_delayed_work(). If this transfer is still in flight when rtl2832_remove() runs, rtl2832_deselect() can reschedule i2c_gate_work after it has been cancelled, causing a use-after-free when kfree(dev) is called. Fix this by calling i2c_mux_del_adapters() before cancel_delayed_work_sync(). Once the mux adapter is unregistered, no new I2C transfers can go through it, so rtl2832_deselect() can no longer reschedule i2c_gate_work. The subsequent cancel_delayed_work_sync() is then guaranteed to be final. Fixes: cddcc40b1b15 ("[media] rtl2832: convert to use an explicit i2c mux core") Cc: stable@vger.kernel.org Reported-by: syzbot+019ced393ab913002b75@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=019ced393ab913002b75 Signed-off-by: Deepanshu Kartikey Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/dvb-frontends/rtl2832.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/media/dvb-frontends/rtl2832.c +++ b/drivers/media/dvb-frontends/rtl2832.c @@ -1115,10 +1115,10 @@ static void rtl2832_remove(struct i2c_cl 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);