diff mbox series

dup: delete error write to stack variable on common path

Message ID YXQCmPai9Sn0qF0T@localhost.localdomain (mailing list archive)
State New, archived
Headers show
Series dup: delete error write to stack variable on common path | expand

Commit Message

Alexey Dobriyan Oct. 23, 2021, 12:39 p.m. UTC
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/file.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

--- a/fs/file.c
+++ b/fs/file.c
@@ -291,10 +291,11 @@  struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int
 	unsigned int open_files, i;
 	struct fdtable *old_fdt, *new_fdt;
 
-	*errorp = -ENOMEM;
 	newf = kmem_cache_alloc(files_cachep, GFP_KERNEL);
-	if (!newf)
+	if (!newf) {
+		*errorp = -ENOMEM;
 		goto out;
+	}
 
 	atomic_set(&newf->count, 1);