Skip to content

Commit

Permalink
bootargs: Fix memory leak in linux_bootargs_get()
Browse files Browse the repository at this point in the history
globalvar_get_match() returns an allocated string which may be
empty. We have to free() the empty string aswell.

Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
saschahauer committed Jan 26, 2018
1 parent 01811d0 commit ecf2350
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/bootargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,21 @@ const char *linux_bootargs_get(void)
bootargs = basprintf("%s mtdparts=%s", linux_bootargs,
parts);
free(linux_bootargs);
free(parts);
linux_bootargs = bootargs;
}

free(parts);

parts = globalvar_get_match("linux.blkdevparts.", ";");
if (strlen(parts)) {
bootargs = basprintf("%s blkdevparts=%s", linux_bootargs,
parts);
free(linux_bootargs);
free(parts);
linux_bootargs = bootargs;
}

free(parts);

return linux_bootargs;
}

Expand Down

0 comments on commit ecf2350

Please sign in to comment.