engines/xnvme: fixes for xnvme ioengine
authorAnkit Kumar <ankit.kumar@samsung.com>
Thu, 22 Dec 2022 04:39:48 +0000 (10:09 +0530)
committerVincent Fu <vincent.fu@samsung.com>
Thu, 22 Dec 2022 13:50:03 +0000 (08:50 -0500)
1. fix error-handling in xnvme_fioe_queue()
2. fix resource-leak in xnvme_fioe_init()

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
engines/xnvme.c

index d86474814ae942992c794380dbd5536e43b30f44..dcc54998b05b062c532b6d0e6cfe101b14bc15ea 100644 (file)
@@ -322,12 +322,15 @@ static int xnvme_fioe_init(struct thread_data *td)
 
        xd->iocq = calloc(td->o.iodepth, sizeof(struct io_u *));
        if (!xd->iocq) {
-               log_err("ioeng->init(): !calloc(), err(%d)\n", errno);
+               free(xd);
+               log_err("ioeng->init(): !calloc(xd->iocq), err(%d)\n", errno);
                return 1;
        }
 
        xd->iovec = calloc(td->o.iodepth, sizeof(*xd->iovec));
        if (!xd->iovec) {
+               free(xd->iocq);
+               free(xd);
                log_err("ioeng->init(): !calloc(xd->iovec), err(%d)\n", errno);
                return 1;
        }
@@ -338,6 +341,10 @@ static int xnvme_fioe_init(struct thread_data *td)
        for_each_file(td, f, i)
        {
                if (_dev_open(td, f)) {
+                       /*
+                        * Note: We are not freeing xd, iocq and iovec. This
+                        * will be done as part of cleanup routine.
+                        */
                        log_err("ioeng->init(): failed; _dev_open(%s)\n", f->file_name);
                        return 1;
                }
@@ -506,9 +513,11 @@ static enum fio_q_status xnvme_fioe_queue(struct thread_data *td, struct io_u *i
 
        default:
                log_err("ioeng->queue(): ENOSYS: %u\n", io_u->ddir);
-               err = -1;
+               xnvme_queue_put_cmd_ctx(ctx->async.queue, ctx);
+
+               io_u->error = ENOSYS;
                assert(false);
-               break;
+               return FIO_Q_COMPLETED;
        }
 
        if (vectored_io) {