In report_kernel () if find_kernel_elf () fails then fname hasn't been
allocated or already freed. Don't free it again.

Brackets around unlikely expression in report_kernel_archive were incorrect
making the check always succeed.

Signed-off-by: Mark Wielaard <[email protected]>
---
 libdwfl/ChangeLog              |    6 ++++++
 libdwfl/linux-kernel-modules.c |    6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index bea55cf..896ae39 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-11  Mark Wielaard  <[email protected]>
+
+       * linux-kernel-modules.c (report_kernel): Only free fname if
+       find_kernel_elf succeeds and allocates it.
+       (report_kernel_archive): Fix brackets around unlikely expression.
+
 2012-11-29  Jan Kratochvil  <[email protected]>
 
        * argp-std.c: Update Copyright year.
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index bafe53c..9bf5f25 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -225,12 +225,12 @@ report_kernel (Dwfl *dwfl, const char **release,
            mod->e_type = ET_DYN;
        }
 
+      free (fname);
+
       if (!report || result < 0)
        close (fd);
     }
 
-  free (fname);
-
   return result;
 }
 
@@ -247,7 +247,7 @@ report_kernel_archive (Dwfl *dwfl, const char **release,
   char *archive;
   if (unlikely ((*release)[0] == '/'
                ? asprintf (&archive, "%s/debug.a", *release)
-               : asprintf (&archive, MODULEDIRFMT "/debug.a", *release)) < 0)
+               : asprintf (&archive, MODULEDIRFMT "/debug.a", *release) < 0))
     return ENOMEM;
 
   int fd = try_kernel_name (dwfl, &archive, false);
-- 
1.7.1

_______________________________________________
elfutils-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/elfutils-devel

Reply via email to