summaryrefslogtreecommitdiff
path: root/tools/objtool
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2025-09-17 09:03:23 -0700
committerJosh Poimboeuf <jpoimboe@kernel.org>2025-10-14 14:45:23 -0700
commit2bb23cbf3f21919ba17cf63404ec0224bd8bf4fb (patch)
tree77b10e2441fbe7d1c2c268fcb7d8a84fcef5f70d /tools/objtool
parent9ebb662fab38a5942100e597b48de5ec9d5e714d (diff)
objtool: Propagate elf_truncate_section() error in elf_write()
Properly check and propagate the return value of elf_truncate_section() to avoid silent failures. Acked-by: Petr Mladek <pmladek@suse.com> Tested-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Diffstat (limited to 'tools/objtool')
-rw-r--r--tools/objtool/elf.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index b009d9feed76..19e249f4783c 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1307,7 +1307,6 @@ static int elf_truncate_section(struct elf *elf, struct section *sec)
for (;;) {
/* get next data descriptor for the relevant section */
data = elf_getdata(s, data);
-
if (!data) {
if (size) {
ERROR("end of section data but non-zero size left\n");
@@ -1343,8 +1342,8 @@ int elf_write(struct elf *elf)
/* Update changed relocation sections and section headers: */
list_for_each_entry(sec, &elf->sections, list) {
- if (sec->truncate)
- elf_truncate_section(elf, sec);
+ if (sec->truncate && elf_truncate_section(elf, sec))
+ return -1;
if (sec_changed(sec)) {
s = elf_getscn(elf->elf, sec->idx);