Skip to contentSkip to conversation

master - cov: fix leaking openned file descriptors

PATCH Zdenek Kabelac 1 participant 1 message Oct 15, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2ab784440a2cbde7448a3f5e315f7e8a8cbcf729
Commit:        2ab784440a2cbde7448a3f5e315f7e8a8cbcf729
Parent:        9b85ecb85b2875bd6743a97147355218879aef3a
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Mon Oct 15 14:34:31 2018 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200

cov: fix leaking openned file descriptors

Once the FD is no longer needed, close it.

---
 tools/pvscan.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/pvscan.c +2 -0
index a4c0244..fd75362 100644
@@ -216,6 +216,8 @@ static void _online_pvid_file_remove_devno(int major, int minor)
 		}
 
 		rv = read(fd, buf_in, sizeof(buf_in));
+		if (close(fd))
+			log_sys_debug("close", path);
 		if (!rv || rv < 0) {
 			log_debug("Failed to read %s", path);
 			continue;