Thread (21 messages) 21 messages, 3 authors, 2018-07-25
STALE2873d
Revisions (4)
  1. rfc [diff vs current]
  2. v1 [diff vs current]
  3. v2 current
  4. v3 [diff vs current]

[PATCH v2 04/10] coresight: platform: Fix leaking device reference

From: suzuki.poulose@arm.com (Suzuki K Poulose)
Date: 2018-07-19 10:55:53
Also in: linux-devicetree, lkml
Subsystem: arm/coresight framework and drivers, hardware tracing facilities, the rest · Maintainers: Suzuki K Poulose, Alexander Shishkin, Linus Torvalds

We don't drop the reference on the remote device while parsing the
connection, held by bus_find_device(). Fix this by duplicating the
device name and dropping the reference.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Kim Phillips <redacted>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 - New in v2
---
 drivers/hwtracing/coresight/of_coresight.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 6c2f95a..c5f664c 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -161,7 +161,9 @@ static int of_coresight_parse_endpoint(struct device *dev,
 		}
 
 		pdata->outports[*i] = endpoint.port;
-		pdata->child_names[*i] = dev_name(rdev);
+		pdata->child_names[*i] = devm_kstrdup(dev,
+						      dev_name(rdev),
+						      GFP_KERNEL);
 		pdata->child_ports[*i] = rendpoint.id;
 		/* Move the index */
 		(*i)++;
@@ -171,6 +173,8 @@ static int of_coresight_parse_endpoint(struct device *dev,
 		of_node_put(rparent);
 	if (rport)
 		of_node_put(rport);
+	if (rdev)
+		put_device(rdev);
 
 	return ret;
 }
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help