Skip to contentSkip to conversation

arm: Elf32_Rel r_offset is unsigned, no need to check <0

PATCH New Ben Dooks (Codethink) 1 participant 1 message Nov 6, 2019 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: Elf32_Rel r_offset is unsigned, no need to check <0

The Elf_Rel r_offset field is an Elf32_Word, which is defined to be an uint32_t, so unsigned. There is no need to check this is less than zero. Fix the following compiler warning:

arch/arm/kernel/module.c:95:21: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

---
Cc: Russell King <[email protected]>
Cc: [email protected]

---
 arch/arm/kernel/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/module.c +1 -1
index deef17f34bd2..0921ce7e48d5 100644
@@ -92,7 +92,7 @@ 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)) {
+		if (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",
 			       module->name, relindex, i, symname,
 			       rel->r_offset, dstsec->sh_size);
Signature · 7 lines
2.24.0.rc1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel