Skip to content

Commit ef20c51

Browse files
DerDakonkees
authored andcommitted
binfmt_elf: simplify error handling in load_elf_phdrs()
The err variable was the same like retval, but capped to <= 0. This is the same as retval as elf_read() never returns positive values. Signed-off-by: Rolf Eike Beer <eb@emlix.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/4137126.7Qn9TF0dmF@mobilepool36.emlix.com
1 parent cfc46ca commit ef20c51

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

fs/binfmt_elf.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ static struct elf_phdr *load_elf_phdrs(const struct elfhdr *elf_ex,
462462
struct file *elf_file)
463463
{
464464
struct elf_phdr *elf_phdata = NULL;
465-
int retval, err = -1;
465+
int retval = -1;
466466
unsigned int size;
467467

468468
/*
@@ -484,15 +484,9 @@ static struct elf_phdr *load_elf_phdrs(const struct elfhdr *elf_ex,
484484

485485
/* Read in the program headers */
486486
retval = elf_read(elf_file, elf_phdata, size, elf_ex->e_phoff);
487-
if (retval < 0) {
488-
err = retval;
489-
goto out;
490-
}
491487

492-
/* Success! */
493-
err = 0;
494488
out:
495-
if (err) {
489+
if (retval) {
496490
kfree(elf_phdata);
497491
elf_phdata = NULL;
498492
}

0 commit comments

Comments
 (0)