memory which malloc for uevent don't free at get_rootdev(), it would cause memory leak, so free it before return.
Signed-off-by: Junyong Sun <[email protected]> --- lib/libf2fs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 55fa391..85107ee 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -637,20 +637,25 @@ char *get_rootdev() ptr = strstr(uevent, "DEVNAME"); if (!ptr) - return NULL; + goto out_free; ret = sscanf(ptr, "DEVNAME=%s\n", buf); if (strlen(buf) == 0) - return NULL; + goto out_free; ret = strlen(buf) + 5; rootdev = malloc(ret + 1); if (!rootdev) - return NULL; + goto out_free; rootdev[ret] = '\0'; snprintf(rootdev, ret + 1, "/dev/%s", buf); + free(uevent); return rootdev; + +out_free: + free(uevent); + return NULL; #endif } -- 2.7.4 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
