Skip to content

Commit

Permalink
core: ofnode: Fix mem leak in error path
Browse files Browse the repository at this point in the history
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: e369e58 ("core: Add functions to set properties in live-tree")
Signed-off-by: Mario Six <[email protected]>
  • Loading branch information
si-gdsys authored and sjg20 committed Nov 14, 2018
1 parent ab88bd2 commit 205dd5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/core/ofnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 205dd5a

Please sign in to comment.