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 1cd8272d5241750c67107536b2a0a1268236e7c0..b766cbf9503af73a144e5cddf1f542ed8e13e3b4 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