]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
of: unittest: fix memory leak in unittest_data_add
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Fri, 4 Oct 2019 18:58:43 +0000 (13:58 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:15:57 +0000 (13:15 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853208
[ 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 <navid.emamdoost@gmail.com>
Reviewed-by: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/of/unittest.c

index f219d1cb7599abc64e163d08029e6263507b737a..af84cb2f85a81f1a7038513e131973cbb9c84d6f 100644 (file)
@@ -1002,6 +1002,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;
        }