binfmt_elf: simplify error handling in load_elf_phdrs()

Rolf Eike Beer
2020-08-05T08:53:55Z

---
fs/binfmt_elf.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 251298d25c8c..64b4b47448af 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -434,7 +434,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;

/*
@@ -456,15 +456,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;
}
--
2.28.0

--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com