From: Felix Gu Date: Tue, 17 Mar 2026 17:21:53 +0000 (+0800) Subject: media: ti: vpe: Fix fwnode_handle leak in vip_probe_complete() X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=34ca1065a4b2cf776c28d7cece6f6c9d90f7e3a3;p=thirdparty%2Fkernel%2Flinux.git media: ti: vpe: Fix fwnode_handle leak in vip_probe_complete() 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 Signed-off-by: Hans Verkuil --- 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 +#include #include #include #include @@ -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; }