t/btrace2fio: fix fd leak on error
authorJens Axboe <axboe@fb.com>
Wed, 15 Oct 2014 01:55:18 +0000 (19:55 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 15 Oct 2014 01:55:18 +0000 (19:55 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
t/btrace2fio.c

index 5666a560c0beca15941ad596a3469a4422264d36..baf29acb9d41a9434ec028f8212f8842f6ff7972 100644 (file)
@@ -870,9 +870,11 @@ static int trace_needs_swap(const char *trace_file, int *swap)
 
        ret = read(fd, &t, sizeof(t));
        if (ret < 0) {
+               close(fd);
                perror("read");
                return 1;
        } else if (ret != sizeof(t)) {
+               close(fd);
                log_err("fio: short read on trace file\n");
                return 1;
        }