Skip to content

Commit 07a3bb9

Browse files
JuliaLawallkdave
authored andcommitted
btrfs: zoned: use vcalloc instead of for vzalloc in btrfs_get_dev_zone_info
Use vcalloc that checks potential multiplication overflows. The changes were done using Coccinelle semantic patch. Reviewed-by: Naohiro Aota <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Julia Lawall <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 706a741 commit 07a3bb9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/zoned.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
465465
* use the cache.
466466
*/
467467
if (populate_cache && bdev_is_zoned(device->bdev)) {
468-
zone_info->zone_cache = vzalloc(sizeof(struct blk_zone) *
469-
zone_info->nr_zones);
468+
zone_info->zone_cache = vcalloc(zone_info->nr_zones,
469+
sizeof(struct blk_zone));
470470
if (!zone_info->zone_cache) {
471471
btrfs_err_in_rcu(device->fs_info,
472472
"zoned: failed to allocate zone cache for %s",

0 commit comments

Comments
 (0)