[PATCH 1/4] libzbc: cleanup init code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make sure every allocated data structure gets freed in case of
unsuccessful libzbc ioengine initialization.

Signed-off-by: Dmitry Fomichev <dmitry.fomichev@xxxxxxx>
---
 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.21.0




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux