]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: ti: vpe: Fix fwnode_handle leak in vip_probe_complete()
authorFelix Gu <ustc.gu@gmail.com>
Tue, 17 Mar 2026 17:21:53 +0000 (01:21 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 5 May 2026 14:57:02 +0000 (16:57 +0200)
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")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/ti/vpe/vip.c

index 0e91e87bda9b9ce58a90fa9a99626e0cec6598e5..a3c5e966f64cab91562661a0162cf4350a6552e3 100644 (file)
@@ -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;
 }