Skip to content

Commit 216830d

Browse files
frowandrobherring
authored andcommitted
of: unittest: kmemleak in of_unittest_platform_populate()
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: fb2caa5 ("of/selftest: add testcase for nodes with same name and address") Reported-by: Erhard F. <[email protected]> Signed-off-by: Frank Rowand <[email protected]> Signed-off-by: Rob Herring <[email protected]>
1 parent b3fb36e commit 216830d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/of/unittest.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,10 +1247,13 @@ static void __init of_unittest_platform_populate(void)
12471247

12481248
of_platform_populate(np, match, NULL, &test_bus->dev);
12491249
for_each_child_of_node(np, child) {
1250-
for_each_child_of_node(child, grandchild)
1251-
unittest(of_find_device_by_node(grandchild),
1250+
for_each_child_of_node(child, grandchild) {
1251+
pdev = of_find_device_by_node(grandchild);
1252+
unittest(pdev,
12521253
"Could not create device for node '%pOFn'\n",
12531254
grandchild);
1255+
of_dev_put(pdev);
1256+
}
12541257
}
12551258

12561259
of_platform_depopulate(&test_bus->dev);

0 commit comments

Comments
 (0)