mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yige Jiang <yigejiang86@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Yige Jiang <yigejiang86@gmail.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] media: tvp5150: Free connectors on probe failure
Date: Thu, 26 Nov 2026 13:56:51 +0800	[thread overview]
Message-ID: <rc-b1-20261110-vc-28-73976feaa334@gmail.com> (raw)

tvp5150_parse_dt() fills core->connectors[] using
v4l2_fwnode_connector_parse() and v4l2_fwnode_connector_add_link().
Each connector then owns a label string and a list of allocated
links, and each link holds a reference on its local and remote
fwnode. Only tvp5150_remove() releases them with
v4l2_fwnode_connector_free().

Every tvp5150_probe() failure after a successful tvp5150_parse_dt()
skips that release. tvp5150_mc_init() and tvp5150_detect_version()
failures return directly, and the control handler, IRQ and
v4l2_async_register_subdev() failures go to the err label, which only
frees the control handler. Each such failed probe, for example when
the decoder does not respond on I2C, leaks the links, the label and
the fwnode references held by the links.

Free the connectors on these error paths, as tvp5150_remove() does.

Fixes: 0556f1d580d4 ("media: tvp5150: add input source selection of_graph support")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2, W=1, CONFIG_VIDEO_TVP5150=y, CONFIG_MEDIA_CONTROLLER=y, CONFIG_OF_DYNAMIC=y, CONFIG_COMPILE_TEST=y; no new warnings versus the base object.
No hardware or runtime test was performed.
The path is taken when tvp5150_probe() fails after DT parsing, e.g. a DT-described decoder that does not answer on I2C.

 drivers/media/i2c/tvp5150.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index c889624..efbb588 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -2158,11 +2158,11 @@ static int tvp5150_probe(struct i2c_client *c)
 
 	res = tvp5150_mc_init(core);
 	if (res)
-		return res;
+		goto err_free_connectors;
 
 	res = tvp5150_detect_version(core);
 	if (res < 0)
-		return res;
+		goto err_free_connectors;
 
 	/*
 	 * Iterate over all available connectors in case they are supported and
@@ -2232,6 +2232,9 @@ static int tvp5150_probe(struct i2c_client *c)
 
 err:
 	v4l2_ctrl_handler_free(&core->hdl);
+err_free_connectors:
+	for (i = 0; i < core->connectors_num; i++)
+		v4l2_fwnode_connector_free(&core->connectors[i].base);
 	return res;
 }
 

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

                 reply	other threads:[~2026-11-26  5:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=rc-b1-20261110-vc-28-73976feaa334@gmail.com \
    --to=yigejiang86@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=stable@vger.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

all inboxes | Powered by JetHome®