Skip to contentSkip to conversation

file-posix: Don't leak fd in hdev_get_max_segments

PATCH Applied Fam Zheng 3 participants 5 messages Mar 14, 2017 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v2 1/1 file-posix: Don't leak fd in hdev_get_max_segments

---
 block/file-posix.c | 3 +++
 1 file changed, 3 insertions(+)
block/file-posix.c +3 -0
index c4c0663..d670be3 100644
@@ -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
Signature · 1 line
2.9.3
Reviewed-by on v2 1/1
#2 lore raw
In reply to Fam Zheng
Quoted 10 lines · Fam Zheng
---
 block/file-posix.c | 3 +++
 1 file changed, 3 insertions(+)
block/file-posix.c +0 -0
index c4c0663..d670be3 100644

block/file-posix.c static int hdev_get_max_segments(const struct stat *st) · line 708

Quoted 6 lines
block/file-posix.c +3 -0
@@ -703,6 +703,9 @@ static int hdev_get_max_segments(const struct stat *st)
     }
 
 out:
+    if (fd != -1) {
+        close(fd);
+    }

Mails crossed - I see I asked about this in reply to v1 after you already sent v2 minutes earlier.

I still think it might be nice to mention a commit id that you are fixing (one of my reply-to-self on your v1), but either way,

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw

Am 14.03.2017 um 17:20 hat Eric Blake geschrieben:

Quoted 21 lines · Fam Zheng
Quoted 10 lines
---
 block/file-posix.c | 3 +++
 1 file changed, 3 insertions(+)
block/file-posix.c +0 -0
index c4c0663..d670be3 100644

block/file-posix.c static int hdev_get_max_segments(const struct stat *st) · line 708

Quoted 6 lines
block/file-posix.c +3 -0
@@ -703,6 +703,9 @@ static int hdev_get_max_segments(const struct stat *st)
     }
 
 out:
+    if (fd != -1) {
+        close(fd);
+    }

Mails crossed - I see I asked about this in reply to v1 after you already sent v2 minutes earlier.

Quoted 4 lines

I still think it might be nice to mention a commit id that you are fixing (one of my reply-to-self on your v1), but either way,

I added a sentence to the commit message: "This fixes a leaked fd introduced in commit 9103f1ce." Sounds good?

Kevin

#4 lore raw
Quoted 22 lines · Kevin Wolf

Am 14.03.2017 um 17:20 hat Eric Blake geschrieben:

Quoted 21 lines · Fam Zheng
Quoted 10 lines
---
 block/file-posix.c | 3 +++
 1 file changed, 3 insertions(+)
block/file-posix.c +0 -0
index c4c0663..d670be3 100644

block/file-posix.c static int hdev_get_max_segments(const struct stat *st) · line 708

Quoted 6 lines
block/file-posix.c +3 -0
@@ -703,6 +703,9 @@ static int hdev_get_max_segments(const struct stat *st)
     }
 
 out:
+    if (fd != -1) {
+        close(fd);
+    }

Mails crossed - I see I asked about this in reply to v1 after you already sent v2 minutes earlier.

Quoted 7 lines
Quoted 4 lines

I still think it might be nice to mention a commit id that you are fixing (one of my reply-to-self on your v1), but either way,

I added a sentence to the commit message: "This fixes a leaked fd introduced in commit 9103f1ce." Sounds good?

Works for me!

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org