summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Rowand <frank.rowand@sony.com>2020-04-17 00:42:47 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-23 11:37:54 +0300
commit5cdd186311860632c2d7aed4e774486b75ce05c4 (patch)
tree3d678037ea1daffb50d5db4a350026c92348603b
parent52a76fc6b59b1b727be6fd297e612fbd68fc677d (diff)
downloadlinux-5cdd186311860632c2d7aed4e774486b75ce05c4.tar.xz
of: unittest: kmemleak in of_unittest_platform_populate()
commit 216830d2413cc61be3f76bc02ffd905e47d2439e upstream. kmemleak reports several memory leaks from devicetree unittest. This is the fix for problem 2 of 5. of_unittest_platform_populate() left an elevated reference count for grandchild nodes (which are platform devices). Fix the platform device reference counts so that the memory will be freed. Fixes: fb2caa50fbac ("of/selftest: add testcase for nodes with same name and address") Reported-by: Erhard F. <erhard_f@mailbox.org> Signed-off-by: Frank Rowand <frank.rowand@sony.com> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/of/unittest.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 3fff96088b45..126a6f4a5f57 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1155,10 +1155,13 @@ static void __init of_unittest_platform_populate(void)
of_platform_populate(np, match, NULL, &test_bus->dev);
for_each_child_of_node(np, child) {
- for_each_child_of_node(child, grandchild)
- unittest(of_find_device_by_node(grandchild),
+ for_each_child_of_node(child, grandchild) {
+ pdev = of_find_device_by_node(grandchild);
+ unittest(pdev,
"Could not create device for node '%pOFn'\n",
grandchild);
+ of_dev_put(pdev);
+ }
}
of_platform_depopulate(&test_bus->dev);