From: Yige Jiang <yigejiang86@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Yige Jiang <yigejiang86@gmail.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH] media: saa7164: Keep the frontend alive during DVB teardown
Date: Tue, 24 Nov 2026 23:45:30 +0800 [thread overview]
Message-ID: <confirmed-20261105-31-0973614e74b7@gmail.com> (raw)
On HVR2205, the frontend is embedded in the si2168 demodulator's private
allocation. Removing the demodulator I2C client frees that allocation,
but saa7164_dvb_unregister() subsequently unregisters and detaches the
frontend through the freed pointer.
Unregister the DVB frontend before removing the I2C clients, and detach
it before removing the demodulator. Keep tuner removal before frontend
detachment: si2157_remove() still accesses the frontend, and on HVR2255
lgdt3306a's release callback can free it during detachment.
Also clear the published demodulator and frontend pointers when HVR2205
frontend attachment fails. The existing error paths already remove the
demodulator, but leave its pointers set. Since the PCI probe continues
after the DVB registration failure, a later remove can otherwise tear
down the freed client and an unregistered frontend again.
Fixes: 504b29cbb0cc ("[media] saa7164: Add Digital TV support for the HVR2255 and HVR2205")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
AI assistance was used for analysis and patch preparation.
Based on next-20261104 (8b7179210b22).
Compile-tested: x86_64, GCC 14.2.0, W=1, drivers/media/pci/saa7164/saa7164-dvb.o;
baseline and patched objects built with no warnings.
Static source review; no hardware, boot, or KASAN test was performed.
drivers/media/pci/saa7164/saa7164-dvb.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c b/drivers/media/pci/saa7164/saa7164-dvb.c
index 3eb749db1ca76163c1b16578ce858a4b54a4e82f..76fe0fc56867434eef87a86d869bac343daeaf47 100644
--- a/drivers/media/pci/saa7164/saa7164-dvb.c
+++ b/drivers/media/pci/saa7164/saa7164-dvb.c
@@ -492,6 +492,13 @@ int saa7164_dvb_unregister(struct saa7164_port *port)
if (dvb->frontend == NULL)
return 0;
+ dvb_net_release(&dvb->net);
+ dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
+ dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
+ dvb_dmxdev_release(&dvb->dmxdev);
+ dvb_dmx_release(&dvb->demux);
+ dvb_unregister_frontend(dvb->frontend);
+
/* remove I2C client for tuner */
client = port->i2c_client_tuner;
if (client) {
@@ -499,6 +506,8 @@ int saa7164_dvb_unregister(struct saa7164_port *port)
i2c_unregister_device(client);
}
+ dvb_frontend_detach(dvb->frontend);
+
/* remove I2C client for demodulator */
client = port->i2c_client_demod;
if (client) {
@@ -506,13 +515,6 @@ int saa7164_dvb_unregister(struct saa7164_port *port)
i2c_unregister_device(client);
}
- dvb_net_release(&dvb->net);
- dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
- dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
- dvb_dmxdev_release(&dvb->dmxdev);
- dvb_dmx_release(&dvb->demux);
- dvb_unregister_frontend(dvb->frontend);
- dvb_frontend_detach(dvb->frontend);
dvb_unregister_adapter(&dvb->adapter);
return 0;
}
@@ -735,6 +737,8 @@ int saa7164_dvb_register(struct saa7164_port *port)
return 0;
frontend_detach:
+ port->i2c_client_demod = NULL;
+ dvb->frontend = NULL;
printk(KERN_ERR "%s() Frontend/I2C initialization failed\n", __func__);
return -1;
}
base-commit: 8b7179210b22f8e48a82c5ceacb9d56a9c4cfec4
reply other threads:[~2026-11-24 15:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=confirmed-20261105-31-0973614e74b7@gmail.com \
--to=yigejiang86@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®