[PATCH 04/10] libdwfl: When we find a compressed image, use that, don't search for others

Mark Wielaard mark@klomp.org
Tue Jun 16 22:25:33 GMT 2020


We try to find a compressed vmlinux image ending with either .gz, bz2 or
xz. Stop searching if we find one. Otherwise we will leak a file descriptor
for an earlier one we opened.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdwfl/ChangeLog              | 5 +++++
 libdwfl/linux-kernel-modules.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 4f1ec9da..44b3ece7 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2020-06-16  Mark Wielaard  <mark@klomp.org>
+
+	* linux-kernel-modules.c (try_kernel_name): Don't try other
+	compressed kernels if we already found an compressed image.
+
 2020-05-09  Mark Wielaard  <mark@klomp.org>
 
 	* find-debuginfo.c (dwfl_standard_find_debuginfo): Return failure
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index 0434f1e5..84a05f28 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -128,7 +128,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug)
 
   if (fd < 0)
     for (size_t i = 0;
-	 i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0];
+	 i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0] && fd < 0;
 	 ++i)
       {
 	char *zname;
-- 
2.18.4



More information about the Elfutils-devel mailing list