]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix two failure condition checks in libdwfl/linux-kernel-modules.c.
authorMark Wielaard <mjw@redhat.com>
Tue, 11 Dec 2012 13:21:01 +0000 (14:21 +0100)
committerMark Wielaard <mjw@redhat.com>
Tue, 11 Dec 2012 21:37:45 +0000 (22:37 +0100)
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 <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/linux-kernel-modules.c

index bea55cfb7f867553545a4c0688d5fd27c17406d9..896ae39001408da08112b51811b698a29af90caa 100644 (file)
@@ -1,3 +1,9 @@
+2012-12-11  Mark Wielaard  <mjw@redhat.com>
+
+       * 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  <jan.kratochvil@redhat.com>
 
        * argp-std.c: Update Copyright year.
index bafe53c083db49698c9d4636f9c2f8eec38a7a5c..9bf5f255f4c4af38b03bdc3f71f76f976939f102 100644 (file)
@@ -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);