Commit ac0f3e30 authored by Lixin Wang's avatar Lixin Wang Committed by Rob Herring

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: default avatarLixin Wang <alan.1.wang@nokia-sbell.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent e0f41456
...@@ -162,6 +162,7 @@ static int of_overlay_apply_single_property(struct of_overlay *ov, ...@@ -162,6 +162,7 @@ static int of_overlay_apply_single_property(struct of_overlay *ov,
bool is_symbols_node) bool is_symbols_node)
{ {
struct property *propn = NULL, *tprop; struct property *propn = NULL, *tprop;
int ret = 0;
/* NOTE: Multiple changes of single properties not supported */ /* NOTE: Multiple changes of single properties not supported */
tprop = of_find_property(target, prop->name, NULL); tprop = of_find_property(target, prop->name, NULL);
...@@ -186,10 +187,16 @@ static int of_overlay_apply_single_property(struct of_overlay *ov, ...@@ -186,10 +187,16 @@ static int of_overlay_apply_single_property(struct of_overlay *ov,
/* not found? add */ /* not found? add */
if (tprop == NULL) if (tprop == NULL)
return of_changeset_add_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);
/* found? update */ if (ret) {
return of_changeset_update_property(&ov->cset, target, propn); kfree(propn->name);
kfree(propn->value);
kfree(propn);
}
return ret;
} }
static int of_overlay_apply_single_device_node(struct of_overlay *ov, static int of_overlay_apply_single_device_node(struct of_overlay *ov,
......
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