[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230615125350.125557-1-cymi20@fudan.edu.cn>
Date: Thu, 15 Jun 2023 05:53:50 -0700
From: Chenyuan Mi <cymi20@...an.edu.cn>
To: axboe@...nel.dk
Cc: sml.silence@...il.com, io-uring@...r.kernel.org,
linux-kernel@...r.kernel.org, Chenyuan Mi <cymi20@...an.edu.cn>
Subject: [PATCH] tools/io_uring: Fix missing check for return value of malloc()
The malloc() function may return NULL when it fails,
which may cause null pointer deference. Add Null
check for return value of malloc().
Found by our static analysis tool.
Signed-off-by: Chenyuan Mi <cymi20@...an.edu.cn>
---
tools/io_uring/io_uring-bench.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/io_uring/io_uring-bench.c b/tools/io_uring/io_uring-bench.c
index 7703f0118385..a7fedfdb9b84 100644
--- a/tools/io_uring/io_uring-bench.c
+++ b/tools/io_uring/io_uring-bench.c
@@ -560,6 +560,11 @@ int main(int argc, char *argv[])
pthread_create(&s->thread, NULL, submitter_fn, s);
fdepths = malloc(8 * s->nr_files);
+ if (!fdepths) {
+ printf("malloc failed");
+ return 1;
+ }
+
reap = calls = done = 0;
do {
unsigned long this_done = 0;
--
2.17.1
Powered by blists - more mailing lists