From: James Clark Date: Wed, 29 May 2024 13:36:26 +0000 (+0100) Subject: coresight: Fix ref leak when of_coresight_parse_endpoint() fails X-Git-Tag: v6.11-rc1~100^2~61^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fcb9cb2fe47294e16067c3cfd25332c8662a115;p=thirdparty%2Fkernel%2Flinux.git coresight: Fix ref leak when of_coresight_parse_endpoint() fails of_graph_get_next_endpoint() releases the reference to the previous endpoint on each iteration, but when parsing fails the loop exits early meaning the last reference is never dropped. Fix it by dropping the refcount in the exit condition. Fixes: d375b356e687 ("coresight: Fix support for sparsely populated ports") Signed-off-by: James Clark Reported-by: Laurent Pinchart Reviewed-by: Laurent Pinchart Signed-off-by: Suzuki K Poulose Link: https://lore.kernel.org/r/20240529133626.90080-1-james.clark@arm.com --- diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 9d550f5697fa8..57a009552cc5c 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -297,8 +297,10 @@ static int of_get_coresight_platform_data(struct device *dev, continue; ret = of_coresight_parse_endpoint(dev, ep, pdata); - if (ret) + if (ret) { + of_node_put(ep); return ret; + } } return 0;