diff mbox series

[liburing,v1,01/10] test/cq-overflow: Don't call `io_uring_queue_exit()` if the ring is not initialized

Message ID 20220810002735.2260172-2-ammar.faizi@intel.com (mailing list archive)
State New
Headers show
Series liburing test fixes | expand

Commit Message

Ammar Faizi Aug. 10, 2022, 12:31 a.m. UTC
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Don't call `io_uring_queue_exit()` if the ring is not initialized.

Fix this:

  + valgrind -q ./cq-overflow.t
  file open: Invalid argument
  ==3054159== Use of uninitialised value of size 8
  ==3054159==    at 0x10A863: io_uring_queue_exit (setup.c:183)
  ==3054159==    by 0x1095DE: test_io.constprop.0 (cq-overflow.c:148)
  ==3054159==    by 0x109266: main (cq-overflow.c:269)
  ==3054159==
  ==3054159== Invalid read of size 4
  ==3054159==    at 0x10A863: io_uring_queue_exit (setup.c:183)
  ==3054159==    by 0x1095DE: test_io.constprop.0 (cq-overflow.c:148)
  ==3054159==    by 0x109266: main (cq-overflow.c:269)
  ==3054159==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
  ==3054159==
  ==3054159==
  ==3054159== Process terminating with default action of signal 11 (SIGSEGV): dumping core
  ==3054159==  Access not within mapped region at address 0x0

Link: https://github.com/axboe/liburing/issues/640
Reported-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 test/cq-overflow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/test/cq-overflow.c b/test/cq-overflow.c
index 0018081..312b414 100644
--- a/test/cq-overflow.c
+++ b/test/cq-overflow.c
@@ -33,14 +33,15 @@  static int test_io(const char *file, unsigned long usecs, unsigned *drops, int f
 	fd = open(file, O_RDONLY | O_DIRECT);
 	if (fd < 0) {
 		perror("file open");
-		goto err;
+		return 1;
 	}
 
 	memset(&p, 0, sizeof(p));
 	ret = io_uring_queue_init_params(ENTRIES, &ring, &p);
 	if (ret) {
+		close(fd);
 		fprintf(stderr, "ring create failed: %d\n", ret);
-		goto err;
+		return 1;
 	}
 	nodrop = 0;
 	if (p.features & IORING_FEAT_NODROP)