From: Julia Lawall Date: Fri, 23 Jun 2023 21:14:43 +0000 (+0200) Subject: btrfs: zoned: use vcalloc instead of for vzalloc in btrfs_get_dev_zone_info X-Git-Tag: block-6.6-2023-09-08~67^2~109 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=07a3bb95ea1f7fa77e360cf3b0f06dff41dbf391;p=linux-block.git 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 Reviewed-by: Johannes Thumshirn Signed-off-by: Julia Lawall Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 72b90bc19a19..b43c4536e685 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -465,8 +465,8 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) * use the cache. */ if (populate_cache && bdev_is_zoned(device->bdev)) { - zone_info->zone_cache = vzalloc(sizeof(struct blk_zone) * - zone_info->nr_zones); + zone_info->zone_cache = vcalloc(zone_info->nr_zones, + sizeof(struct blk_zone)); if (!zone_info->zone_cache) { btrfs_err_in_rcu(device->fs_info, "zoned: failed to allocate zone cache for %s",