[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] RISC-V: prevent null pointer dereference
From: |
David Michael |
Subject: |
[PATCH] RISC-V: prevent null pointer dereference |
Date: |
Thu, 30 Apr 2020 11:06:52 -0400 |
Signed-off-by: David Michael <address@hidden>
---
Hi,
I tried to test the Linux RISC-V UEFI stub by cross-compiling this
branch with binutils 2.34 and GCC 9.3.0:
https://github.com/atishp04/linux/tree/uefi_riscv_pr
It results in a segfault in ld while linking vmlinux because the pointer
h->root.u.def.section is NULL in one instance. This change fixes the
segfault and results in a usable UEFI kernel, but I am not familiar with
this code, so I don't know if it is the correct behavior.
Can someone verify this? Let me know if you need configs etc.
Thanks.
David
bfd/elfnn-riscv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 8fcb1067..65b4f141 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -4161,7 +4161,8 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec,
symval = 0;
sym_sec = bfd_und_section_ptr;
}
- else if (h->root.u.def.section->output_section == NULL
+ else if (h->root.u.def.section == NULL
+ || h->root.u.def.section->output_section == NULL
|| (h->root.type != bfd_link_hash_defined
&& h->root.type != bfd_link_hash_defweak))
continue;
--
2.21.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] RISC-V: prevent null pointer dereference,
David Michael <=