From d060babce1d2bc02af6476daace1398a8396db71 Mon Sep 17 00:00:00 2001 From: Dmitry Fomichev Date: Wed, 27 Jan 2021 13:19:08 +0900 Subject: [PATCH] zbd: return ENOMEM if zone buffer allocation fails parse_zone_info() function tries to allocate a buffer of ZBD_REPORT_MAX_ZONES zone descriptors and exits if this allocation fails. The problem is that it returns 0 error code in this case and the caller may interpret this as the success. Just return ENOMEM if we can't allocate that buffer. Signed-off-by: Dmitry Fomichev Reviewed-by: Shin'ichiro Kawasaki Signed-off-by: Jens Axboe --- zbd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zbd.c b/zbd.c index f2599bd4..46992746 100644 --- a/zbd.c +++ b/zbd.c @@ -443,7 +443,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f) struct fio_zone_info *p; uint64_t zone_size, offset; struct zoned_block_device_info *zbd_info = NULL; - int i, j, ret = 0; + int i, j, ret = -ENOMEM; zones = calloc(ZBD_REPORT_MAX_ZONES, sizeof(struct zbd_zone)); if (!zones) @@ -475,7 +475,6 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f) zbd_info = scalloc(1, sizeof(*zbd_info) + (nr_zones + 1) * sizeof(zbd_info->zone_info[0])); - ret = -ENOMEM; if (!zbd_info) goto out; mutex_init_pshared(&zbd_info->mutex); -- 2.25.1