Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Correction to previous: don't leak newuc if copyout() fa...



details:   https://anonhg.NetBSD.org/src/rev/5c394f571d79
branches:  trunk
changeset: 744183:5c394f571d79
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Jan 26 19:08:09 2020 +0000

description:
Correction to previous: don't leak newuc if copyout() fails.

diffstat:

 sys/compat/netbsd32/netbsd32_lwp.c |  13 ++++++-------
 sys/kern/sys_lwp.c                 |  13 ++++++-------
 2 files changed, 12 insertions(+), 14 deletions(-)

diffs (70 lines):

diff -r 22d36e0a7ccc -r 5c394f571d79 sys/compat/netbsd32/netbsd32_lwp.c
--- a/sys/compat/netbsd32/netbsd32_lwp.c        Sun Jan 26 19:06:24 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_lwp.c        Sun Jan 26 19:08:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_lwp.c,v 1.20 2020/01/25 15:41:52 ad Exp $     */
+/*     $NetBSD: netbsd32_lwp.c,v 1.21 2020/01/26 19:08:09 ad Exp $     */
 
 /*
  *  Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.20 2020/01/25 15:41:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.21 2020/01/26 19:08:09 ad Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -84,12 +84,11 @@
 
        error = copyout(&l2->l_lid, SCARG_P32(uap, new_lwp),
            sizeof(l2->l_lid));
-       if (error != 0)
-               lwp_exit(l2);
-       else
+       if (error == 0) { 
                lwp_start(l2, SCARG(uap, flags));
-       return error;
-
+               return 0;
+       }
+       lwp_exit(l2);
  fail:
        kmem_free(newuc, sizeof(ucontext_t));
        return error;
diff -r 22d36e0a7ccc -r 5c394f571d79 sys/kern/sys_lwp.c
--- a/sys/kern/sys_lwp.c        Sun Jan 26 19:06:24 2020 +0000
+++ b/sys/kern/sys_lwp.c        Sun Jan 26 19:08:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_lwp.c,v 1.72 2020/01/25 15:41:52 ad Exp $  */
+/*     $NetBSD: sys_lwp.c,v 1.73 2020/01/26 19:08:09 ad Exp $  */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.72 2020/01/25 15:41:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.73 2020/01/26 19:08:09 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -156,12 +156,11 @@
                goto fail;
 
        error = copyout(&l2->l_lid, SCARG(uap, new_lwp), sizeof(l2->l_lid));
-       if (error != 0)
-               lwp_exit(l2);
-       else
+       if (error == 0) {
                lwp_start(l2, SCARG(uap, flags));
-       return error;
-
+               return 0;
+       }
+       lwp_exit(l2);
  fail:
        kmem_free(newuc, sizeof(ucontext_t));
        return error;



Home | Main Index | Thread Index | Old Index