linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] binfmt_elf: fix documented return value for load_elf_phdrs()
@ 2020-08-05  7:52 Rolf Eike Beer
  2020-08-05  8:53 ` binfmt_elf: simplify error handling in load_elf_phdrs() Rolf Eike Beer
  0 siblings, 1 reply; 4+ messages in thread
From: Rolf Eike Beer @ 2020-08-05  7:52 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel; +Cc: Ralf Baechle, Paul Burton, Alexander Viro

This function has never returned anything but a plain NULL.

Fixes: 6a8d38945cf4e6e819d6b550250615db763065a0
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 9fe3b51c116a..251298d25c8c 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -428,7 +428,7 @@ static int elf_read(struct file *file, void *buf, size_t len, loff_t pos)
  *
  * Loads ELF program headers from the binary file elf_file, which has the ELF
  * header pointed to by elf_ex, into a newly allocated array. The caller is
- * responsible for freeing the allocated data. Returns an ERR_PTR upon failure.
+ * responsible for freeing the allocated data. Returns NULL upon failure.
  */
 static struct elf_phdr *load_elf_phdrs(const struct elfhdr *elf_ex,
 				       struct file *elf_file)
-- 
2.28.0


-- 
Rolf Eike Beer, emlix GmbH, http://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 related	[flat|nested] 4+ messages in thread

* binfmt_elf: simplify error handling in load_elf_phdrs()
  2020-08-05  7:52 [PATCH] binfmt_elf: fix documented return value for load_elf_phdrs() Rolf Eike Beer
@ 2020-08-05  8:53 ` Rolf Eike Beer
  0 siblings, 0 replies; 4+ messages in thread
From: Rolf Eike Beer @ 2020-08-05  8:53 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel, Alexander Viro; +Cc: Ralf Baechle

---
 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
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 related	[flat|nested] 4+ messages in thread

* Re: [PATCH] binfmt_elf: fix documented return value for load_elf_phdrs()
  2022-10-19  7:43 [PATCH] binfmt_elf: fix documented return value for load_elf_phdrs() Rolf Eike Beer
@ 2022-10-25 22:24 ` Kees Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2022-10-25 22:24 UTC (permalink / raw)
  To: Al Viro, ebiederm, eb; +Cc: Kees Cook, linux-kernel, linux-mm, linux-fsdevel

On Wed, 19 Oct 2022 09:43:01 +0200, Rolf Eike Beer wrote:
> This function has never returned anything but a plain NULL.

Applied to for-next/execve, thanks!

[1/1] binfmt_elf: fix documented return value for load_elf_phdrs()
      https://git.kernel.org/kees/c/cfc46ca4fdca

-- 
Kees Cook


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

* [PATCH] binfmt_elf: fix documented return value for load_elf_phdrs()
@ 2022-10-19  7:43 Rolf Eike Beer
  2022-10-25 22:24 ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Rolf Eike Beer @ 2022-10-19  7:43 UTC (permalink / raw)
  To: Alexander Viro, Eric Biederman, Kees Cook
  Cc: linux-fsdevel, linux-mm, linux-kernel

This function has never returned anything but a plain NULL.

Fixes: 6a8d38945cf4 ("binfmt_elf: Hoist ELF program header loading to a function")
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 63c7ebb0da89..cfd5f7ad019d 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -456,7 +456,7 @@ static unsigned long maximum_alignment(struct elf_phdr *cmds, int nr)
  *
  * Loads ELF program headers from the binary file elf_file, which has the ELF
  * header pointed to by elf_ex, into a newly allocated array. The caller is
- * responsible for freeing the allocated data. Returns an ERR_PTR upon failure.
+ * responsible for freeing the allocated data. Returns NULL upon failure.
  */
 static struct elf_phdr *load_elf_phdrs(const struct elfhdr *elf_ex,
 				       struct file *elf_file)
-- 
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 related	[flat|nested] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05  7:52 [PATCH] binfmt_elf: fix documented return value for load_elf_phdrs() Rolf Eike Beer
2020-08-05  8:53 ` binfmt_elf: simplify error handling in load_elf_phdrs() Rolf Eike Beer
2022-10-19  7:43 [PATCH] binfmt_elf: fix documented return value for 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;
as well as URLs for NNTP newsgroup(s).