Blame 0001-ioengines-fix-crash-with-enghelp-option.patch

Eric Sandeen ca502c
From 2459bd33b3dbb7a34f28c612d595311a6bc7593d Mon Sep 17 00:00:00 2001
Eric Sandeen ca502c
From: Vincent Fu <vincent.fu@samsung.com>
Eric Sandeen ca502c
Date: Wed, 4 Aug 2021 18:29:05 +0000
Eric Sandeen ca502c
Subject: [PATCH] ioengines: fix crash with --enghelp option
Eric Sandeen ca502c
Eric Sandeen ca502c
Since f6931a1dd35896433c8cc2e10de51372a2c496c4 commands like the
Eric Sandeen ca502c
following segfault:
Eric Sandeen ca502c
Eric Sandeen ca502c
fio --enghelp=sg
Eric Sandeen ca502c
fio --enghelp=sg,sg_write_mode
Eric Sandeen ca502c
Eric Sandeen ca502c
This is because free_ioengine() assumes that td->io_ops is not NULL.
Eric Sandeen ca502c
Make this true when free_ioengine() is called by
Eric Sandeen ca502c
fio_show_ioengine_help() to avoid the crash.
Eric Sandeen ca502c
Eric Sandeen ca502c
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
Eric Sandeen ca502c
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Eric Sandeen ca502c
---
Eric Sandeen ca502c
 ioengines.c | 10 +++++-----
Eric Sandeen ca502c
 1 file changed, 5 insertions(+), 5 deletions(-)
Eric Sandeen ca502c
Eric Sandeen ca502c
diff --git a/ioengines.c b/ioengines.c
Eric Sandeen ca502c
index dd61af07..d08a511a 100644
Eric Sandeen ca502c
--- a/ioengines.c
Eric Sandeen ca502c
+++ b/ioengines.c
Eric Sandeen ca502c
@@ -692,17 +692,17 @@ int fio_show_ioengine_help(const char *engine)
Eric Sandeen ca502c
 	}
Eric Sandeen ca502c
 
Eric Sandeen ca502c
 	td.o.ioengine = (char *)engine;
Eric Sandeen ca502c
-	io_ops = load_ioengine(&td);
Eric Sandeen ca502c
+	td.io_ops = load_ioengine(&td);
Eric Sandeen ca502c
 
Eric Sandeen ca502c
-	if (!io_ops) {
Eric Sandeen ca502c
+	if (!td.io_ops) {
Eric Sandeen ca502c
 		log_info("IO engine %s not found\n", engine);
Eric Sandeen ca502c
 		return 1;
Eric Sandeen ca502c
 	}
Eric Sandeen ca502c
 
Eric Sandeen ca502c
-	if (io_ops->options)
Eric Sandeen ca502c
-		ret = show_cmd_help(io_ops->options, sep);
Eric Sandeen ca502c
+	if (td.io_ops->options)
Eric Sandeen ca502c
+		ret = show_cmd_help(td.io_ops->options, sep);
Eric Sandeen ca502c
 	else
Eric Sandeen ca502c
-		log_info("IO engine %s has no options\n", io_ops->name);
Eric Sandeen ca502c
+		log_info("IO engine %s has no options\n", td.io_ops->name);
Eric Sandeen ca502c
 
Eric Sandeen ca502c
 	free_ioengine(&td);
Eric Sandeen ca502c
 	return ret;
Eric Sandeen ca502c
-- 
Eric Sandeen ca502c
2.31.1
Eric Sandeen ca502c