Commit f81309b2 authored by Navid Emamdoost's avatar Navid Emamdoost Committed by Stefan Bader

of: unittest: fix memory leak in unittest_data_add

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

[ Upstream commit e13de8fe ]

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: b951f9dc ("Enabling OF selftest to run without machine's devicetree")
Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: default avatarFrank Rowand <frowand.list@gmail.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent b0ae47e7
...@@ -924,6 +924,7 @@ static int __init unittest_data_add(void) ...@@ -924,6 +924,7 @@ static int __init unittest_data_add(void)
of_fdt_unflatten_tree(unittest_data, &unittest_data_node); of_fdt_unflatten_tree(unittest_data, &unittest_data_node);
if (!unittest_data_node) { if (!unittest_data_node) {
pr_warn("%s: No tree to attach; not running tests\n", __func__); pr_warn("%s: No tree to attach; not running tests\n", __func__);
kfree(unittest_data);
return -ENODATA; return -ENODATA;
} }
of_node_set_flag(unittest_data_node, OF_DETACHED); of_node_set_flag(unittest_data_node, OF_DETACHED);
......
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