From: Mark Wielaard Date: Tue, 11 Dec 2012 13:21:01 +0000 (+0100) Subject: Fix two failure condition checks in libdwfl/linux-kernel-modules.c. X-Git-Tag: elfutils-0.156~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76c54597cad951a8027d8b1a5f19eb557c22ebcb;p=thirdparty%2Felfutils.git Fix two failure condition checks in libdwfl/linux-kernel-modules.c. 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 --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index bea55cfb7..896ae3900 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2012-12-11 Mark Wielaard + + * 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 * argp-std.c: Update Copyright year. diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index bafe53c08..9bf5f255f 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);