From: Daniel van Gerpen <daniel@vangerpen.de>
To: linux-mtd@lists.infradead.org
Subject: [PATCH] ubi-utils: Fix file descriptor leaks in libubi
Date: Sun, 30 Mar 2014 00:52:10 +0100 [thread overview]
Message-ID: <20140330005210.6df43941@abel> (raw)
Signed-off-by: Daniel van Gerpen <daniel@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
next reply other threads:[~2014-03-29 23:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-29 23:52 Daniel van Gerpen [this message]
2014-03-31 9:53 ` [PATCH] ubi-utils: Fix file descriptor leaks in libubi Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140330005210.6df43941@abel \
--to=daniel@vangerpen.de \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox