[PATCH] media: pt1: Detach the frontend when registration fails

From: Wentao Liang

Date: Tue Nov 03 2026 - 04:52:38 EST


dvb_register_frontend() allocates the frontend private data and sets up
two references: one is released by dvb_unregister_frontend() and the
other by dvb_frontend_detach(). If registration fails,
pt1_init_frontend() returns without calling dvb_frontend_detach(), and
the error path in pt1_init_frontends() only releases the tuner and demod
modules. The frontend private data allocated by dvb_register_frontend()
is never freed.

Call dvb_frontend_detach() before returning the registration error.

Fixes: 4d1f413e820c ("V4L/DVB: pt1: Support Earthsoft PT2")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/media/pci/pt1/pt1.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index 7cce6576b4cb..4bf9db375173 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -947,8 +947,10 @@ static int pt1_init_frontend(struct pt1_adapter *adap, struct dvb_frontend *fe)
fe->ops.init = pt1_wakeup;

ret = dvb_register_frontend(&adap->adap, fe);
- if (ret < 0)
+ if (ret < 0) {
+ dvb_frontend_detach(fe);
return ret;
+ }

adap->fe = fe;
return 0;
--
2.34.1