[PATCH 2/2] media: as102: fix frontend leak on dvb_register() error path

From: xiaopeitux

Date: Wed Jun 03 2026 - 05:36:13 EST


From: Pei Xiao <xiaopei01@xxxxxxxxxx>

In as102_dvb_register(), if dvb_register_frontend() fails, the error
path jumps directly to label "efereg", which releases the dmxdev
resources but does not detach the already allocated frontend
(in as102_attach kzalloc struct as102_state*).
This results in a memory leak of the frontend structure.

Fix this by adding a new label "fail_frontend" that calls
dvb_frontend_detach().

Reported-by: Shuangpeng Bai <shuangpeng.kernel@xxxxxxxxx>
Closes: https://lore.kernel.org/lkml/DAD7161C-A1DA-422E-BBC5-2893ABDC2DD0@xxxxxxxxx/
Fixes: d6317c68f332 ("[media] as102: promote it out of staging")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Pei Xiao <xiaopei01@xxxxxxxxxx>
---
drivers/media/usb/as102/as102_drv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/as102/as102_drv.c b/drivers/media/usb/as102/as102_drv.c
index 6b1d3528a0a7..b57ae8357a73 100644
--- a/drivers/media/usb/as102/as102_drv.c
+++ b/drivers/media/usb/as102/as102_drv.c
@@ -338,7 +338,7 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
if (ret < 0) {
dev_err(dev, "%s: as102_dvb_register_frontend() failed: %d",
__func__, ret);
- goto efereg;
+ goto fail_frontend;
}

/* init bus mutex for token locking */
@@ -358,6 +358,8 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
pr_info("Registered device %s", as102_dev->name);
return 0;

+fail_frontend:
+ dvb_frontend_detach(dvb->frontend);
efereg:
dvb_dmxdev_release(&as102_dev->dvb_dmxdev);
edmxdinit:
--
2.25.1