On Wed Mar 18 01:21:53 2026 +0800, Felix Gu wrote:
> 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: [email protected]
> Signed-off-by: Felix Gu <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 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 0e91e87bda9b..a3c5e966f64c 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;
 }
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to