From: Mario Six Date: Thu, 4 Oct 2018 07:22:24 +0000 (+0200) Subject: core: ofnode: Fix mem leak in error path X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-logo.png?a=commitdiff_plain;h=205dd5afe59db2a471b756fa04c30232fa29e5c6;p=u-boot.git 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 --- 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, return -ENOMEM; new->name = strdup(propname); - if (!new->name) + if (!new->name) { + free(new); return -ENOMEM; + } new->value = (void *)value; new->length = len;