* [PATCH] media: saa7164: Keep the frontend alive during DVB teardown
@ 2026-11-24 15:45 Yige Jiang
0 siblings, 0 replies; only message in thread
From: Yige Jiang @ 2026-11-24 15:45 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Yige Jiang, linux-media, linux-kernel, stable
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 15:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 15:45 [PATCH] media: saa7164: Keep the frontend alive during DVB teardown Yige Jiang
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®