diff mbox

[PULL,3/8] file-posix: Don't leak fd in hdev_get_max_segments

Message ID 1489756546-27142-4-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf March 17, 2017, 1:15 p.m. UTC
From: Fam Zheng <famz@redhat.com>

This fixes a leaked fd introduced in commit 9103f1ce.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/file-posix.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/block/file-posix.c b/block/file-posix.c
index ac6bd9f..53febd3 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -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