Fix fd leak in cache line checking
authorJens Axboe <jens.axboe@oracle.com>
Tue, 9 Jun 2009 11:05:32 +0000 (13:05 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 9 Jun 2009 11:05:32 +0000 (13:05 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
os/os-linux.h

index 1cd8272..b766cbf 100644 (file)
@@ -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