Skip to content

Commit

Permalink
of: unittest: fix memory leak in unittest_data_add
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Navidem authored and robherring committed Oct 23, 2019
1 parent 9af865d commit e13de8f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/of/unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ static int __init unittest_data_add(void)
of_fdt_unflatten_tree(unittest_data, NULL, &unittest_data_node);
if (!unittest_data_node) {
pr_warn("%s: No tree to attach; not running tests\n", __func__);
kfree(unittest_data);
return -ENODATA;
}

Expand Down

0 comments on commit e13de8f

Please # to comment.