ioengines: fix crash with --enghelp option
authorVincent Fu <vincent.fu@samsung.com>
Wed, 4 Aug 2021 18:29:05 +0000 (18:29 +0000)
committerJens Axboe <axboe@kernel.dk>
Wed, 4 Aug 2021 18:49:57 +0000 (12:49 -0600)
Since f6931a1dd35896433c8cc2e10de51372a2c496c4 commands like the
following segfault:

fio --enghelp=sg
fio --enghelp=sg,sg_write_mode

This is because free_ioengine() assumes that td->io_ops is not NULL.
Make this true when free_ioengine() is called by
fio_show_ioengine_help() to avoid the crash.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
ioengines.c

index dd61af07a4432c802ba53d18535c2dc44ea2a8bf..d08a511a0635eccc090528dfa2ff242fd5719209 100644 (file)
@@ -692,17 +692,17 @@ int fio_show_ioengine_help(const char *engine)
        }
 
        td.o.ioengine = (char *)engine;
-       io_ops = load_ioengine(&td);
+       td.io_ops = load_ioengine(&td);
 
-       if (!io_ops) {
+       if (!td.io_ops) {
                log_info("IO engine %s not found\n", engine);
                return 1;
        }
 
-       if (io_ops->options)
-               ret = show_cmd_help(io_ops->options, sep);
+       if (td.io_ops->options)
+               ret = show_cmd_help(td.io_ops->options, sep);
        else
-               log_info("IO engine %s has no options\n", io_ops->name);
+               log_info("IO engine %s has no options\n", td.io_ops->name);
 
        free_ioengine(&td);
        return ret;