From 891660e4292bcf85d966249bd12bb308ed61416c Mon Sep 17 00:00:00 2001 From: Dmitry Fomichev Date: Tue, 26 May 2020 06:32:53 +0900 Subject: [PATCH] libzbc: cleanup init code Make sure every allocated data structure gets freed in case of unsuccessful libzbc ioengine initialization. Reviewed-by: Damien Le Moal Signed-off-by: Dmitry Fomichev Signed-off-by: Jens Axboe --- engines/libzbc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/engines/libzbc.c b/engines/libzbc.c index 8c682de6..2f6b4583 100644 --- a/engines/libzbc.c +++ b/engines/libzbc.c @@ -92,15 +92,12 @@ static int libzbc_open_dev(struct thread_data *td, struct fio_file *f, if (ret) { log_err("%s: zbc_open() failed, err=%d\n", f->file_name, ret); - return ret; + goto err; } ret = libzbc_get_dev_info(ld, f); - if (ret) { - zbc_close(ld->zdev); - free(ld); - return ret; - } + if (ret) + goto err_close; td->io_ops_data = ld; out: @@ -108,6 +105,12 @@ out: *p_ld = ld; return 0; + +err_close: + zbc_close(ld->zdev); +err: + free(ld); + return ret; } static int libzbc_close_dev(struct thread_data *td) -- 2.25.1