aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel van Gerpen <daniel@vangerpen.de>2014-03-30 00:52:10 +0100
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-03-31 12:52:38 +0300
commiteac3108f123f7fcdfd1f2e368adb5729111574b3 (patch)
tree743f3283580f1492999d3d3d61d3238751aaaa69
parent4f291fbfa3ea677fd476466c82492a69ce6e562d (diff)
ubi-utils: Fix file descriptor leaks in libubi
Amended by Artem. Signed-off-by: Daniel van Gerpen <daniel@vangerpen.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r--ubi-utils/libubi.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
index 598191e..1e08b7d 100644
--- a/ubi-utils/libubi.c
+++ b/ubi-utils/libubi.c
@@ -188,10 +188,8 @@ static int read_data(const char *file, void *buf, int buf_len)
goto out_error;
}
- if (close(fd)) {
- sys_errmsg("close failed on \"%s\"", file);
- return -1;
- }
+ if (close(fd))
+ return sys_errmsg("close failed on \"%s\"", file);
return rd;
@@ -420,6 +418,9 @@ static int vol_node2nums(struct libubi *lib, const char *node, int *dev_num,
return -1;
}
+ if (close(fd))
+ return sys_errmsg("close failed on \"%s\"", file);
+
*dev_num = i;
*vol_id = minor - 1;
errno = 0;
@@ -911,6 +912,9 @@ int ubi_probe_node(libubi_t desc, const char *node)
if (fd == -1)
goto out_not_ubi;
+ if (close(fd))
+ sys_errmsg("close failed on \"%s\"", file);
+
return 2;
out_not_ubi: