[PATCH] media: cx231xx: Fix potential frontend leak on registration failure

From: Guangshuo Li

Date: Fri Nov 13 2026 - 14:43:07 EST


If registering the second frontend fails, fail_frontend1 detaches both
frontends without unregistering the already registered first frontend.

Move the label before its unregister call so the registration is
unwound before the frontend is detached.

This issue was found by our static analysis tool under development.

Fixes: bdaacc32e9b2 ("media: cx231xx: Add second frontend option")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/media/usb/cx231xx/cx231xx-dvb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 472a4405a105..4dffadd31bb5 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -577,8 +577,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
fail_dmx:
if (dvb->frontend[1])
dvb_unregister_frontend(dvb->frontend[1]);
- dvb_unregister_frontend(dvb->frontend[0]);
fail_frontend1:
+ dvb_unregister_frontend(dvb->frontend[0]);
if (dvb->frontend[1])
dvb_frontend_detach(dvb->frontend[1]);
fail_frontend0:

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4