summaryrefslogtreecommitdiff
path: root/drivers/hwtracing
diff options
context:
space:
mode:
authorJames Clark <james.clark@arm.com>2024-05-29 16:36:26 +0300
committerSuzuki K Poulose <suzuki.poulose@arm.com>2024-06-07 13:30:30 +0300
commit7fcb9cb2fe47294e16067c3cfd25332c8662a115 (patch)
tree94fc18a644f391fc0162e99f92d6020c0a270980 /drivers/hwtracing
parentc3f38fa61af77b49866b006939479069cd451173 (diff)
downloadlinux-7fcb9cb2fe47294e16067c3cfd25332c8662a115.tar.xz
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 <james.clark@arm.com> Reported-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20240529133626.90080-1-james.clark@arm.com
Diffstat (limited to 'drivers/hwtracing')
-rw-r--r--drivers/hwtracing/coresight/coresight-platform.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index 9d550f5697fa..57a009552cc5 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;