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@xxxxxxxxxxx> --- 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