diff options
author | Frank Rowand <frank.rowand@sony.com> | 2020-04-16 16:42:47 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-24 08:01:17 +0200 |
commit | b712f00a98c10b6bca4f89cbe5cd04189b1dae7a (patch) | |
tree | 8f39c5585a0182ff2c1d3019286c7dbcd9940cce /drivers/of | |
parent | f463b1273df7624f9a8a5d4de53e42207061b90c (diff) |
of: unittest: kmemleak in of_unittest_platform_populate()
[ Upstream commit 216830d2413cc61be3f76bc02ffd905e47d2439e ]
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: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/unittest.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 4bf6a9db6ac0..55c98f119df2 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -887,10 +887,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 '%s'\n", grandchild->name); + of_dev_put(pdev); + } } of_platform_depopulate(&test_bus->dev); |