diff options
author | Navid Emamdoost <navid.emamdoost@gmail.com> | 2019-10-04 14:58:43 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2019-10-23 15:42:44 -0400 |
commit | e13de8fe0d6a51341671bbe384826d527afe8d44 (patch) | |
tree | aa4c4d87587b0284841b945334bb17a7b22bb113 /drivers/of/unittest.c | |
parent | 9af865d95bd730c1d1035acd5dd6df105da98d0c (diff) |
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: b951f9dc7f25 ("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>
Diffstat (limited to 'drivers/of/unittest.c')
-rw-r--r-- | drivers/of/unittest.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 480a21e2ed39..92e895d86458 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
@@ -1207,6 +1207,7 @@ static int __init unittest_data_add(void) | |||
1207 | of_fdt_unflatten_tree(unittest_data, NULL, &unittest_data_node); | 1207 | of_fdt_unflatten_tree(unittest_data, NULL, &unittest_data_node); |
1208 | if (!unittest_data_node) { | 1208 | if (!unittest_data_node) { |
1209 | pr_warn("%s: No tree to attach; not running tests\n", __func__); | 1209 | pr_warn("%s: No tree to attach; not running tests\n", __func__); |
1210 | kfree(unittest_data); | ||
1210 | return -ENODATA; | 1211 | return -ENODATA; |
1211 | } | 1212 | } |
1212 | 1213 | ||