linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] binfmt_elf: simplify error handling in load_elf_phdrs()
@ 2022-10-19  7:52 Rolf Eike Beer
  2022-10-25 22:24 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Rolf Eike Beer @ 2022-10-19  7:52 UTC (permalink / raw)
  To: Alexander Viro, Eric Biederman, Kees Cook
  Cc: linux-fsdevel, linux-mm, linux-kernel

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>
---
 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 cfd5f7ad019d..1fdc92e95170 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;
 	}
-- 
2.37.3

-- 
Rolf Eike Beer, emlix GmbH, https://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-25 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19  7:52 [PATCH] binfmt_elf: simplify error handling in load_elf_phdrs() Rolf Eike Beer
2022-10-25 22:24 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox