Commit 6995e67d authored by Frank Rowand's avatar Frank Rowand Committed by Kleber Sacilotto de Souza

of: unittest: kmemleak in of_unittest_platform_populate()

BugLink: https://bugs.launchpad.net/bugs/1875905

[ Upstream commit 216830d2 ]

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: fb2caa50 ("of/selftest: add testcase for nodes with same name and address")
Reported-by: default avatarErhard F. <erhard_f@mailbox.org>
Signed-off-by: default avatarFrank Rowand <frank.rowand@sony.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 10a2f608
......@@ -812,10 +812,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment