fio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anuj Gupta <anuj20.g@samsung.com>
To: axboe@kernel.dk
Cc: vincent.fu@samsung.com, fio@vger.kernel.org,
	ankit.kumar@samsung.com, anuj1072538@gmail.com,
	Anuj Gupta <anuj20.g@samsung.com>
Subject: [PATCH] t/io_uring: fix error handling for setup_ring
Date: Thu, 27 Apr 2023 20:40:04 +0530	[thread overview]
Message-ID: <20230427151004.1146679-1-anuj20.g@samsung.com> (raw)
In-Reply-To: CGME20230427094952epcas5p32967ed548e18e60ea3134a03aa046bb8@epcas5p3.samsung.com

s->sq_ring.ring_entries and s->cq_ring.ring_entries will be NULL,
incase setup_ring fails. This will cause a segmentation fault.

In case setup_ring fails, bail out by setting finish.

Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
 t/io_uring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/t/io_uring.c b/t/io_uring.c
index 6b0efef8..e00f278d 100644
--- a/t/io_uring.c
+++ b/t/io_uring.c
@@ -1059,12 +1059,14 @@ static int submitter_init(struct submitter *s)
 		err = 0;
 	} else if (!aio) {
 		err = setup_ring(s);
-		sprintf(buf, "Engine=io_uring, sq_ring=%d, cq_ring=%d\n", *s->sq_ring.ring_entries, *s->cq_ring.ring_entries);
+		if (!err)
+			sprintf(buf, "Engine=io_uring, sq_ring=%d, cq_ring=%d\n", *s->sq_ring.ring_entries, *s->cq_ring.ring_entries);
 	} else {
 		sprintf(buf, "Engine=aio\n");
 		err = setup_aio(s);
 	}
 	if (err) {
+		finish = 1;
 		printf("queue setup failed: %s, %d\n", strerror(errno), err);
 		return 1;
 	}
@@ -1282,6 +1284,9 @@ static void *submitter_uring_fn(void *data)
 	submitter_init(s);
 #endif
 
+	if (finish)
+		return NULL;
+
 	if (register_ring)
 		io_uring_register_ring(s);
 
-- 
2.25.1


       reply	other threads:[~2023-04-27  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230427094952epcas5p32967ed548e18e60ea3134a03aa046bb8@epcas5p3.samsung.com>
2023-04-27 15:10 ` Anuj Gupta [this message]
2023-04-27 11:48   ` [PATCH] t/io_uring: fix error handling for setup_ring Jens Axboe
2023-04-27 11:53     ` Jens Axboe
2023-04-27 12:26       ` Anuj gupta
2023-04-27 13:22         ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230427151004.1146679-1-anuj20.g@samsung.com \
    --to=anuj20.g@samsung.com \
    --cc=ankit.kumar@samsung.com \
    --cc=anuj1072538@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    --cc=vincent.fu@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).