Skip to contentSkip to conversation

master - cov: Close a FD on error

PATCH Marian Csontos 1 participant 1 message Dec 19, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f05104af76e26f0757df1500540e767dd889ae71
Commit:        f05104af76e26f0757df1500540e767dd889ae71
Parent:        b068f21f6a24094936a33269067c18373b48f2cd
Author:        Marian Csontos <[email protected]>
AuthorDate:    Wed Dec 19 16:29:31 2018 +0100
Committer:     Marian Csontos <[email protected]>
CommitterDate: Wed Dec 19 16:29:31 2018 +0100

cov: Close a FD on error

---
 tools/pvscan.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
tools/pvscan.c +2 -1
index 2a884df..6841f20 100644
@@ -290,7 +290,8 @@ static int _online_pvid_file_create(struct device *dev)
 		rv = write(fd, buf, len);
 		if (rv < 0) {
 			log_error("Failed to write fd %d buf %s dev %s to %s: %d",
-				  fd, buf, dev_name(dev), path, errno);
+			          fd, buf, dev_name(dev), path, errno);
+			close(fd);
 			return 0;
 		}
 		len -= rv;