It needs to fix to handle error case of {c,m}alloc().
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
get_node_info(sbi, nid, &ni);
node_blk = calloc(BLOCK_SZ, 1);
+ ASSERT(node_blk);
+
dev_read_block(node_blk, ni.blk_addr);
for (i = 0; i < idx; i++, (*ofs)++) {
get_node_info(sbi, nid, &ni);
node_blk = calloc(BLOCK_SZ, 1);
+ ASSERT(node_blk);
+
dev_read_block(node_blk, ni.blk_addr);
DBG(1, "Node ID [0x%x]\n", nid);
continue;
}
name = calloc(name_len + 1, 1);
+ ASSERT(name);
+
memcpy(name, filenames[i], name_len);
slots = (name_len + F2FS_SLOT_LEN - 1) / F2FS_SLOT_LEN;
char buf[F2FS_BLKSIZE];
sbi->raw_super = malloc(sizeof(struct f2fs_super_block));
+ if (!sbi->raw_super)
+ return -ENOMEM;
if (dev_read_block(buf, sb_addr))
return -1;
/* Read the 1st cp block in this CP pack */
cp_page_1 = malloc(PAGE_SIZE);
+ ASSERT(cp_page_1);
+
if (dev_read_block(cp_page_1, cp_addr) < 0)
goto invalid_cp1;
/* Read the 2nd cp block in this CP pack */
cp_page_2 = malloc(PAGE_SIZE);
+ ASSERT(cp_page_2);
+
cp_addr += get_cp(cp_pack_total_block_count) - 1;
if (dev_read_block(cp_page_2, cp_addr) < 0)
src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP);
dst_bitmap = malloc(bitmap_size);
+ if (!dst_bitmap)
+ return -ENOMEM;
+
memcpy(dst_bitmap, src_bitmap, bitmap_size);
sit_i->sit_base_addr = get_sb(sit_blkaddr);
start = start_sum_block(sbi);
kaddr = (char *)malloc(PAGE_SIZE);
+ ASSERT(kaddr);
+
ret = dev_read_block(kaddr, start++);
ASSERT(ret >= 0);
}
sum_blk = (struct f2fs_summary_block *)malloc(PAGE_SIZE);
+ ASSERT(sum_blk);
+
ret = dev_read_block(sum_blk, blk_addr);
ASSERT(ret >= 0);
}
uevent = malloc(ret + 1);
+ ASSERT(uevent);
+
uevent[ret] = '\0';
ret = read(fd, uevent, ret);
* the file system. In this case, we should not format.
*/
st_buf = malloc(sizeof(struct stat));
+ ASSERT(st_buf);
+
if (stat(path, st_buf) == 0 && S_ISBLK(st_buf->st_mode)) {
int fd = open(path, O_RDONLY | O_EXCL);
}
blocks_count = c.device_size / F2FS_BLKSIZE;
blocks = calloc(blocks_count, sizeof(char *));
+ if (!blocks) {
+ MSG(0, "\tError: Calloc Failed for blocks!!!\n");
+ return -1;
+ }
return sparse_file_foreach_chunk(f2fs_sparse_file, true, false,
sparse_import_segment, NULL);