Skip to content

Commit e13de8f

Browse files
Navidemrobherring
authored andcommitted
of: unittest: fix memory leak in unittest_data_add
In unittest_data_add, a copy buffer is created via kmemdup. This buffer is leaked if of_fdt_unflatten_tree fails. The release for the unittest_data buffer is added. Fixes: b951f9d ("Enabling OF selftest to run without machine's devicetree") Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com> Reviewed-by: Frank Rowand <frowand.list@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 9af865d commit e13de8f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: drivers/of/unittest.c

+1
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ static int __init unittest_data_add(void)
12071207
of_fdt_unflatten_tree(unittest_data, NULL, &unittest_data_node);
12081208
if (!unittest_data_node) {
12091209
pr_warn("%s: No tree to attach; not running tests\n", __func__);
1210+
kfree(unittest_data);
12101211
return -ENODATA;
12111212
}
12121213

0 commit comments

Comments
 (0)