This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] libdwfl: Don't leak fd on error in linux-proc-maps.c (grovel_auxv).
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 15 May 2014 16:58:09 +0200
- Subject: [PATCH] libdwfl: Don't leak fd on error in linux-proc-maps.c (grovel_auxv).
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