From: Mark Wielaard <mjw@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH] libdwfl: Don't leak fd on error in linux-proc-maps.c (grovel_auxv).
Date: Thu, 15 May 2014 16:58:09 +0200 [thread overview]
Message-ID: <1400165889-19420-1-git-send-email-mjw@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
libdwfl/ChangeLog | 4 ++++
libdwfl/linux-proc-maps.c | 6 +++++-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 2cf0752..2fd2a1a 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2014-05-15 Mark Wielaard <mjw@redhat.com>
+
+ * linux-proc-maps.c (grovel_auxv): Close fd on error.
+
2014-05-02 Mark Wielaard <mjw@redhat.com>
* dwfl_module_getdwarf: Remove ENABLE_DWZ ifdefs so find_debug_altlink
diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index b6620ac..d085834 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -116,7 +116,11 @@ grovel_auxv (pid_t pid, Dwfl *dwfl, GElf_Addr *sysinfo_ehdr)
eu_static_assert (sizeof d.a64 == sizeof d.a32);
nread = pread_retry (fd, d.a64, sizeof d.a64, offset);
if (nread < 0)
- return errno;
+ {
+ int ret = errno;
+ close (fd);
+ return ret;
+ }
for (size_t a32i = 0; a32i < nread / sizeof d.a32[0]; a32i++)
{
const Elf32_auxv_t *a32 = d.a32 + a32i;
--
1.7.1
next reply other threads:[~2014-05-15 14:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-15 14:58 Mark Wielaard [this message]
2014-05-16 11:36 Petr Machata
2014-05-17 20:18 Mark Wielaard
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=1400165889-19420-1-git-send-email-mjw@redhat.com \
--to=mjw@redhat.com \
--cc=elfutils-devel@lists.fedorahosted.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).