summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
authorLixin Wang <alan.1.wang@nokia-sbell.com>2017-10-16 12:54:32 +0300
committerRob Herring <robh@kernel.org>2017-10-17 16:55:54 +0300
commitac0f3e30d87e593dc1460d5f0407662073281d93 (patch)
tree71292f8edde4465dc025ef624cb29a2458f222d0 /drivers/of
parente0f4145685ec7b477f6166ee819125107388a249 (diff)
downloadlinux-ac0f3e30d87e593dc1460d5f0407662073281d93.tar.xz
of: overlay: fix memory leak related to duplicated property
Function of_changeset_add_property or of_changeset_update_property may fails. In this case the property just allocated is never deallocated. Signed-off-by: Lixin Wang <alan.1.wang@nokia-sbell.com> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/overlay.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 8ecfee31ab6d..af3b9a16df26 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -162,6 +162,7 @@ static int of_overlay_apply_single_property(struct of_overlay *ov,
bool is_symbols_node)
{
struct property *propn = NULL, *tprop;
+ int ret = 0;
/* NOTE: Multiple changes of single properties not supported */
tprop = of_find_property(target, prop->name, NULL);
@@ -186,10 +187,16 @@ static int of_overlay_apply_single_property(struct of_overlay *ov,
/* not found? add */
if (tprop == NULL)
- return of_changeset_add_property(&ov->cset, target, propn);
-
- /* found? update */
- return of_changeset_update_property(&ov->cset, target, propn);
+ ret = of_changeset_add_property(&ov->cset, target, propn);
+ else /* found? update */
+ ret = of_changeset_update_property(&ov->cset, target, propn);
+
+ if (ret) {
+ kfree(propn->name);
+ kfree(propn->value);
+ kfree(propn);
+ }
+ return ret;
}
static int of_overlay_apply_single_device_node(struct of_overlay *ov,