summaryrefslogtreecommitdiff
path: root/fs/binfmt_elf.c
diff options
context:
space:
mode:
authorRolf Eike Beer <eb@emlix.com>2022-10-19 09:52:16 +0200
committerKees Cook <keescook@chromium.org>2022-10-25 15:19:52 -0700
commitef20c5139c3157b5c6eda46f496952bddffe9ad6 (patch)
tree5e5db511c06280e4369980f55b2fc4c92336fd56 /fs/binfmt_elf.c
parentcfc46ca4fdcaef6f0215f56d89162400aee402e3 (diff)
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
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r--fs/binfmt_elf.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 71df1a3c2dac..528e2ac8931f 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -462,7 +462,7 @@ static struct elf_phdr *load_elf_phdrs(const struct elfhdr *elf_ex,
struct file *elf_file)
{
struct elf_phdr *elf_phdata = NULL;
- int retval, err = -1;
+ int retval = -1;
unsigned int size;
/*
@@ -484,15 +484,9 @@ static struct elf_phdr *load_elf_phdrs(const struct elfhdr *elf_ex,
/* Read in the program headers */
retval = elf_read(elf_file, elf_phdata, size, elf_ex->e_phoff);
- if (retval < 0) {
- err = retval;
- goto out;
- }
- /* Success! */
- err = 0;
out:
- if (err) {
+ if (retval) {
kfree(elf_phdata);
elf_phdata = NULL;
}