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: v6.6.17~3697^2~144 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07a3bb95ea1f7fa77e360cf3b0f06dff41dbf391;p=platform%2Fkernel%2Flinux-rpi.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 72b90bc..b43c453 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",