From 7aaed66455cc172bd9a3db1893925aa156ba2e14 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:26:05 +0300 Subject: [PATCH] grub-mkimage: fix potential NULL pointer dereference Move fatal check whether symtab_section is NULL before first reference. Found by: Coverity scan. --- util/grub-mkimagexx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 0a1ac9e51..3c76d0708 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1539,6 +1539,8 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, symtab_section = s; break; } + if (! symtab_section) + grub_util_error ("%s", _("no symbol table")); #ifdef MKIMAGE_ELF32 if (image_target->elf_target == EM_ARM) @@ -1577,8 +1579,6 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, } #endif - if (! symtab_section) - grub_util_error ("%s", _("no symbol table")); } else {