Skip to content

Commit

Permalink
btrfs: zoned: use kmemdup() to replace kmalloc + memcpy
Browse files Browse the repository at this point in the history
Fix memdup.cocci warning:
fs/btrfs/zoned.c:1198:23-30: WARNING opportunity for kmemdup

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Kai Song <songkai01@inspur.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Kai Song authored and David Sterba committed Oct 26, 2021
1 parent 0cf9b24 commit 64259ba
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/btrfs/zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,14 +1195,12 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)

map = em->map_lookup;

cache->physical_map = kmalloc(map_lookup_size(map->num_stripes), GFP_NOFS);
cache->physical_map = kmemdup(map, map_lookup_size(map->num_stripes), GFP_NOFS);
if (!cache->physical_map) {
ret = -ENOMEM;
goto out;
}

memcpy(cache->physical_map, map, map_lookup_size(map->num_stripes));

alloc_offsets = kcalloc(map->num_stripes, sizeof(*alloc_offsets), GFP_NOFS);
if (!alloc_offsets) {
ret = -ENOMEM;
Expand Down

0 comments on commit 64259ba

Please sign in to comment.