All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Kenny <darren.kenny@oracle.com>
To: grub-devel@gnu.org
Cc: darren.kenny@oracle.com
Subject: [PATCH 1/2] grub-mkimage: Only check aarch64 relocations when built for aarch64
Date: Wed, 16 Mar 2022 17:25:04 +0000	[thread overview]
Message-ID: <a0802259765b7304c38d9b48cad152fcd970ef19.1647451397.git.darren.kenny@oracle.com> (raw)

Coverity flagged the switch checks for R_AARCH64_* as being logically
dead code, since it could never happen on x86 due to the masking of the
values earlier in the code.

A check for building on __ARM_ARCH (which gcc and clang define) and for
MKIMAGE_ELF64 (which GRUB defines) has been added to avoid this dead
code being built in.

Fixes: CID 158599

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
---
 util/grub-mkimagexx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index 9762bc80e40d..9ff31083f746 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -1631,6 +1631,7 @@ translate_relocation_pe (struct translate_context *ctx,
 	}
       break;
     case EM_AARCH64:
+#if defined(MKIMAGE_ELF64) && defined(__ARM_ARCH)
       switch (ELF_R_TYPE (info))
 	{
 	case R_AARCH64_ABS64:
@@ -1666,6 +1667,7 @@ translate_relocation_pe (struct translate_context *ctx,
 			   (unsigned int) ELF_R_TYPE (info));
 	  break;
 	}
+#endif /* defined(MKIMAGE_ELF64) && define(__ARM_ARCH) */
       break;
       break;
 #if defined(MKIMAGE_ELF32)
-- 
2.27.0



             reply	other threads:[~2022-03-16 17:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 17:25 Darren Kenny [this message]
2022-03-16 17:25 ` [PATCH 2/2] kern: Ensure that parser allocated memory is not leaked Darren Kenny
2022-03-16 18:19   ` Daniel Kiper
2022-03-16 18:17 ` [PATCH 1/2] grub-mkimage: Only check aarch64 relocations when built for aarch64 Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0802259765b7304c38d9b48cad152fcd970ef19.1647451397.git.darren.kenny@oracle.com \
    --to=darren.kenny@oracle.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.