Use kmemdup instead of kzalloc and memcpy.

Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
Acked-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
Alexandru Gheorghiu 2013-03-28 02:24:53 +02:00 коммит произвёл Jaegeuk Kim
Родитель 953a3e27e1
Коммит 79b5793be4
2 изменённых файлов: 6 добавлений и 9 удалений

Просмотреть файл

@ -1666,19 +1666,17 @@ static int init_node_manager(struct f2fs_sb_info *sbi)
spin_lock_init(&nm_i->free_nid_list_lock); spin_lock_init(&nm_i->free_nid_list_lock);
rwlock_init(&nm_i->nat_tree_lock); rwlock_init(&nm_i->nat_tree_lock);
nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP);
nm_i->init_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); nm_i->init_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid);
nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid);
nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP);
nm_i->nat_bitmap = kzalloc(nm_i->bitmap_size, GFP_KERNEL);
if (!nm_i->nat_bitmap)
return -ENOMEM;
version_bitmap = __bitmap_ptr(sbi, NAT_BITMAP); version_bitmap = __bitmap_ptr(sbi, NAT_BITMAP);
if (!version_bitmap) if (!version_bitmap)
return -EFAULT; return -EFAULT;
/* copy version bitmap */ nm_i->nat_bitmap = kmemdup(version_bitmap, nm_i->bitmap_size,
memcpy(nm_i->nat_bitmap, version_bitmap, nm_i->bitmap_size); GFP_KERNEL);
if (!nm_i->nat_bitmap)
return -ENOMEM;
return 0; return 0;
} }

Просмотреть файл

@ -1403,10 +1403,9 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
bitmap_size = __bitmap_size(sbi, SIT_BITMAP); bitmap_size = __bitmap_size(sbi, SIT_BITMAP);
src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP); src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP);
dst_bitmap = kzalloc(bitmap_size, GFP_KERNEL); dst_bitmap = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL);
if (!dst_bitmap) if (!dst_bitmap)
return -ENOMEM; return -ENOMEM;
memcpy(dst_bitmap, src_bitmap, bitmap_size);
/* init SIT information */ /* init SIT information */
sit_i->s_ops = &default_salloc_ops; sit_i->s_ops = &default_salloc_ops;