The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
To: mchehab@kernel.org
Cc: kees@kernel.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Shuangpeng Bai <shuangpeng.kernel@gmail.com>
Subject: [PATCH] media: ttusb-dec: detach frontend on registration failure
Date: Thu,  2 Jul 2026 14:29:06 -0400	[thread overview]
Message-ID: <20260702182906.2613718-1-shuangpeng.kernel@gmail.com> (raw)
In-Reply-To: <D1EE37E7-8CCB-4621-8105-0229FADF5855@gmail.com>

ttusb_dec_probe() calls dvb_register_frontend() after attaching the
frontend. If dvb_register_frontend() fails after allocating
fe->frontend_priv, the DVB frontend core has initialized the frontend
refcount and drops only the registration reference before returning.

The remaining detach reference must still be released via
dvb_frontend_detach(). Calling the frontend driver release callback
directly frees the ttusbdecfe state, but bypasses the DVB frontend core
cleanup and leaks struct dvb_frontend_private.

Use dvb_frontend_detach() on frontend registration failure.

Fixes: a574359e2e71 ("media: dvb-core: Fix ignored return value in dvb_register_frontend()")
Closes: https://lore.kernel.org/all/D1EE37E7-8CCB-4621-8105-0229FADF5855@gmail.com/
Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
---
 drivers/media/usb/ttusb-dec/ttusb_dec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index 825a3875989d..8566fb074092 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -1694,8 +1694,7 @@ static int ttusb_dec_probe(struct usb_interface *intf,
 	} else {
 		if (dvb_register_frontend(&dec->adapter, dec->fe)) {
 			printk("budget-ci: Frontend registration failed!\n");
-			if (dec->fe->ops.release)
-				dec->fe->ops.release(dec->fe);
+			dvb_frontend_detach(dec->fe);
 			dec->fe = NULL;
 		}
 	}
-- 
2.43.0


      reply	other threads:[~2026-07-02 18:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 20:41 [BUG] media: ttusb-dec: kmemleak reports dvb_frontend_private leak after frontend registration failure Shuangpeng
2026-07-02 18:29 ` Shuangpeng Bai [this message]

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=20260702182906.2613718-1-shuangpeng.kernel@gmail.com \
    --to=shuangpeng.kernel@gmail.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@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