From: Navid Emamdoost Date: Fri, 4 Oct 2019 18:58:43 +0000 (-0500) Subject: of: unittest: fix memory leak in unittest_data_add X-Git-Tag: v4.9.200~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0228cd262dda0916948b52a74b88fa1f8b3cc810;p=platform%2Fkernel%2Flinux-amlogic.git of: unittest: fix memory leak in unittest_data_add [ Upstream commit e13de8fe0d6a51341671bbe384826d527afe8d44 ] 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 Reviewed-by: Frank Rowand Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 0a1ebbbd3f16..92530525e355 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -933,6 +933,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; } of_node_set_flag(unittest_data_node, OF_DETACHED);