Skip to contentSkip to conversation

ARM: module: remove 'always false' statement

PATCH New Austin Kim 1 participant 1 message Sep 30, 2019 Arm (32-bit)

lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/1 ARM: module: remove 'always false' statement

The each field of 'struct elf32_rel' is declared as below. typedef struct elf32_rel {
Elf32_Addr r_offset;
Elf32_Word r_info;
} Elf32_Rel;

typedef __u32 Elf32_Addr;
typedef __u32 Elf32_Word;

This means that 'r_offset' and 'r_info' could contain non-negative value. So 'always false' statement can be dropped.

---
 arch/arm/kernel/module.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/kernel/module.c +3 -3
index deef17f..617de32 100644
@@ -83,7 +83,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 #endif
 
 		offset = ELF32_R_SYM(rel->r_info);
-		if (offset < 0 || offset > (symsec->sh_size / sizeof(Elf32_Sym))) {
+		if (offset > (symsec->sh_size / sizeof(Elf32_Sym))) {
 			pr_err("%s: section %u reloc %u: bad relocation sym offset\n",
 				module->name, relindex, i);
 			return -ENOEXEC;
@@ -92,8 +92,8 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 		sym = ((Elf32_Sym *)symsec->sh_addr) + offset;
 		symname = strtab + sym->st_name;
 
-		if (rel->r_offset < 0 || rel->r_offset > dstsec->sh_size - sizeof(u32)) {
-			pr_err("%s: section %u reloc %u sym '%s': out of bounds relocation, offset %d size %u\n",
+		if (rel->r_offset > dstsec->sh_size - sizeof(u32)) {
+			pr_err("%s: section %u reloc %u sym '%s': out of bounds relocation, offset %u size %u\n",
 			       module->name, relindex, i, symname,
 			       rel->r_offset, dstsec->sh_size);
 			return -ENOEXEC;
Signature · 1 line
2.6.2