[PATCH] ubi-utils: Fix file descriptor leaks in libubi

Daniel van Gerpen daniel at vangerpen.de
Sat Mar 29 19:52:10 EDT 2014


Signed-off-by: Daniel van Gerpen <daniel at vangerpen.de>
---
 ubi-utils/libubi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
index 598191e..c2d67af 100644
--- a/ubi-utils/libubi.c
+++ b/ubi-utils/libubi.c
@@ -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;
 
-- 
1.8.3.2



More information about the linux-mtd mailing list