All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Gu <ustc.gu@gmail.com>
To: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Dale Farnsworth <dale@farnsworth.org>,
	Benoit Parrot <bparrot@ti.com>,
	 Hans Verkuil <hverkuil+cisco@kernel.org>,
	 Sukrut Bellary <sbellary@baylibre.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Felix Gu <ustc.gu@gmail.com>
Subject: [PATCH 1/3] media: ti: vpe: Fix fwnode_handle leak in vip_probe_complete()
Date: Wed, 18 Mar 2026 01:21:53 +0800	[thread overview]
Message-ID: <20260318-vip-v1-1-5fdcdbd01829@gmail.com> (raw)
In-Reply-To: <20260318-vip-v1-0-5fdcdbd01829@gmail.com>

In vip_probe_complete(), the fwnode_handle reference is not released
if the loop continues via the default switch case or if alloc_port()
fails. This results in a reference count leak.

Switch to using the __free(fwnode_handle) cleanup attribute to ensure
the reference is automatically released when the handle goes out of
scope.

Fixes: fc2873aa4a21 ("media: ti: vpe: Add the VIP driver")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/media/platform/ti/vpe/vip.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/ti/vpe/vip.c b/drivers/media/platform/ti/vpe/vip.c
index a4b616a5ece7..01d27769cd10 100644
--- a/drivers/media/platform/ti/vpe/vip.c
+++ b/drivers/media/platform/ti/vpe/vip.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/cleanup.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
@@ -3389,7 +3390,6 @@ static int vip_probe_complete(struct platform_device *pdev)
 	struct vip_port *port;
 	struct vip_dev *dev;
 	struct device_node *parent = pdev->dev.of_node;
-	struct fwnode_handle *ep = NULL;
 	unsigned int syscon_args[5];
 	int ret, i, slice_id, port_id, p;
 
@@ -3411,8 +3411,9 @@ static int vip_probe_complete(struct platform_device *pdev)
 		ctrl->syscon_bit_field[i] = syscon_args[i + 1];
 
 	for (p = 0; p < (VIP_NUM_PORTS * VIP_NUM_SLICES); p++) {
-		ep = fwnode_graph_get_next_endpoint_by_regs(of_fwnode_handle(parent),
-							    p, 0);
+		struct fwnode_handle *ep __free(fwnode_handle) =
+			fwnode_graph_get_next_endpoint_by_regs(
+				of_fwnode_handle(parent), p, 0);
 		if (!ep)
 			continue;
 
@@ -3447,7 +3448,6 @@ static int vip_probe_complete(struct platform_device *pdev)
 		port = dev->ports[port_id];
 
 		vip_register_subdev_notify(port, ep);
-		fwnode_handle_put(ep);
 	}
 	return 0;
 }

-- 
2.43.0


  reply	other threads:[~2026-03-17 17:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 17:21 [PATCH 0/3] media: ti: vpe: three small fixes Felix Gu
2026-03-17 17:21 ` Felix Gu [this message]
2026-03-17 17:21 ` [PATCH 2/3] media: ti: vpe: Fix the error code of devm_request_irq() Felix Gu
2026-03-18  9:00   ` Markus Elfring
2026-03-17 17:21 ` [PATCH 3/3] media: ti: vpe: Fix the error code of devm_kzalloc() in vip_probe_slice() Felix Gu
2026-03-18  9:22   ` Markus Elfring

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=20260318-vip-v1-1-5fdcdbd01829@gmail.com \
    --to=ustc.gu@gmail.com \
    --cc=bparrot@ti.com \
    --cc=dale@farnsworth.org \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sbellary@baylibre.com \
    --cc=y-abhilashchandra@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.