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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Nov 2019 10:27:30 +0000 (11:27 +0100)
commitfcc3f7c810c3bc595ce179ea4d9e18f506fd0d03
treeb7d3d0c26c5d93db2dbdb7dea83b1069b348a996
parentc56b9da70d0918d545db1a18c33a61284813395e
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 <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>
drivers/of/unittest.c