aboutsummaryrefslogtreecommitdiff
path: root/block/file-posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/file-posix.c')
-rw-r--r--block/file-posix.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/block/file-posix.c b/block/file-posix.c
index c4c06637ef..53febd3767 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -686,7 +686,7 @@ static int hdev_get_max_segments(const struct stat *st)
goto out;
}
do {
- ret = read(fd, buf, sizeof(buf));
+ ret = read(fd, buf, sizeof(buf) - 1);
} while (ret == -1 && errno == EINTR);
if (ret < 0) {
ret = -errno;
@@ -703,6 +703,9 @@ static int hdev_get_max_segments(const struct stat *st)
}
out:
+ if (fd != -1) {
+ close(fd);
+ }
g_free(sysfspath);
return ret;
#else