Skip to contentSkip to conversation

ubi-utils: Fix file descriptor leaks in libubi

PATCH In review Daniel van Gerpen 2 participants 2 messages Mar 29, 2014 – Mar 31, 2014 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ubi-utils: Fix file descriptor leaks in libubi

---
 ubi-utils/libubi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
ubi-utils/libubi.c +10 -0
index 598191e..c2d67af 100644
@@ -419,6 +419,11 @@ static int vol_node2nums(struct libubi *lib, const char *node, int *dev_num,
 		errno = ENODEV;
 		return -1;
 	}
+	
+	if (close(fd)) {
+		sys_errmsg("close failed on \"%s\"", file);
+		return -1;
+	}
 
 	*dev_num = i;
 	*vol_id = minor - 1;
@@ -910,6 +915,11 @@ int ubi_probe_node(libubi_t desc, const char *node)
 	fd = open(file, O_RDONLY);
 	if (fd == -1)
 		goto out_not_ubi;
+	
+        if (close(fd)) {
+		sys_errmsg("close failed on \"%s\"", file);
+		return -1;
+	}
 
 	return 2;
 
Signature · 1 line
1.8.3.2