sload.f2fs: fix memory leak
authortaebum81.kim <taebum81.kim@lge.com>
Mon, 5 Nov 2018 06:43:37 +0000 (15:43 +0900)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 21 Nov 2018 19:38:23 +0000 (11:38 -0800)
Dynamic memory stored in 'xattr_node' allocated through function 'calloc'
at line 98 can be lost at line 111
Dynamic memory stored in 'inode' allocated through function 'calloc'
at line 144 can be lost at line 227

Signed-off-by: taebum81.kim <taebum81.kim@lge.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/xattr.c

index 1d15d1b..b13e5ee 100644 (file)
@@ -108,6 +108,9 @@ static void write_all_xattrs(struct f2fs_sb_info *sbi,
 
        ret = dev_write_block(xattr_node, blkaddr);
        ASSERT(ret >= 0);
+
+       if (xnid)
+               free(xattr_node);
 }
 
 int f2fs_setxattr(struct f2fs_sb_info *sbi, nid_t ino, int index, const char *name,
@@ -223,6 +226,7 @@ int f2fs_setxattr(struct f2fs_sb_info *sbi, nid_t ino, int index, const char *na
        ret = dev_write_block(inode, ni.blk_addr);
        ASSERT(ret >= 0);
 exit:
+       free(inode);
        free(base_addr);
        return error;
 }