From 0992b9b38fcdd6f91e19f524c199b8cd3e1cda13 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 2 Aug 2022 09:56:25 -0600 Subject: [PATCH] t/io_uring: check read of home node file Signed-off-by: Jens Axboe --- t/io_uring.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/io_uring.c b/t/io_uring.c index ea702043..35bf1956 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -641,14 +641,18 @@ static int detect_node(struct submitter *s, const char *name) #ifdef CONFIG_LIBNUMA const char *base = basename(name); char str[128]; - int fd, node; + int ret, fd, node; sprintf(str, "/sys/block/%s/device/numa_node", base); fd = open(str, O_RDONLY); if (fd < 0) return -1; - read(fd, str, sizeof(str)); + ret = read(fd, str, sizeof(str)); + if (ret < 0) { + close(fd); + return -1; + } node = atoi(str); s->numa_node = node; close(fd); -- 2.25.1