fsck.f2fs: fix to avoid accessing invalid memory address
authorChao Yu <yuchao0@huawei.com>
Mon, 23 Apr 2018 06:01:45 +0000 (14:01 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 14 Jul 2018 05:46:00 +0000 (22:46 -0700)
This patch adds to check return value of calloc in write_superblock().

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/mount.c

index 2ad78d1..0e67a6b 100644 (file)
@@ -2234,6 +2234,7 @@ void write_superblock(struct f2fs_super_block *new_sb)
        u_int8_t *buf;
 
        buf = calloc(BLOCK_SZ, 1);
+       ASSERT(buf);
 
        memcpy(buf + F2FS_SUPER_OFFSET, new_sb, sizeof(*new_sb));
        for (index = 0; index < 2; index++) {