aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Six2018-10-04 02:22:24 -0500
committerSimon Glass2018-11-14 11:16:27 -0600
commit205dd5afe59db2a471b756fa04c30232fa29e5c6 (patch)
tree938390ce9e76c1257bccfaac34a6eab778125d15 /drivers
parentab88bd2b6a160310953a230d4a4c334ea6a65d3b (diff)
downloadu-boot-205dd5afe59db2a471b756fa04c30232fa29e5c6.tar.gz
u-boot-205dd5afe59db2a471b756fa04c30232fa29e5c6.tar.xz
u-boot-205dd5afe59db2a471b756fa04c30232fa29e5c6.zip
core: ofnode: Fix mem leak in error path
A newly created property is currently not freed if a name could not be allocated. This patch fixes the resulting memory leak in the error patch. Reported-by: Coverity (CID: 184085) Fixes: e369e58df79c ("core: Add functions to set properties in live-tree") Signed-off-by: Mario Six <mario.six@gdsys.cc>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/ofnode.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index b7b7ad3a62..d9b5280b2d 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -831,8 +831,10 @@ int ofnode_write_prop(ofnode node, const char *propname, int len,
831 return -ENOMEM; 831 return -ENOMEM;
832 832
833 new->name = strdup(propname); 833 new->name = strdup(propname);
834 if (!new->name) 834 if (!new->name) {
835 free(new);
835 return -ENOMEM; 836 return -ENOMEM;
837 }
836 838
837 new->value = (void *)value; 839 new->value = (void *)value;
838 new->length = len; 840 new->length = len;