From ec76f15a4ae995c06db6c6dda6a6fa41b189f613 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 9 Jun 2009 13:05:32 +0200 Subject: [PATCH] Fix fd leak in cache line checking Signed-off-by: Jens Axboe --- os/os-linux.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/os/os-linux.h b/os/os-linux.h index 1cd8272d..b766cbf9 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -263,10 +263,13 @@ static inline int arch_cache_line_size(void) return -1; ret = read(fd, size, sizeof(size)); + + close(fd); + if (ret <= 0) return -1; - - return atoi(size); + else + return atoi(size); } #endif -- 2.25.1