Source-Changes-HG archive

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

[src/trunk]: src/sys/kern fix leak on error from pty_fill_ptmget (Ilya Zykov)



details:   https://anonhg.NetBSD.org/src/rev/e900fb5ba60e
branches:  trunk
changeset: 327874:e900fb5ba60e
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 19 18:11:17 2014 +0000

description:
fix leak on error from pty_fill_ptmget (Ilya Zykov)

diffstat:

 sys/kern/tty_ptm.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r d332f94a0075 -r e900fb5ba60e sys/kern/tty_ptm.c
--- a/sys/kern/tty_ptm.c        Wed Mar 19 18:09:00 2014 +0000
+++ b/sys/kern/tty_ptm.c        Wed Mar 19 18:11:17 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_ptm.c,v 1.29 2014/03/16 05:20:30 dholland Exp $    */
+/*     $NetBSD: tty_ptm.c,v 1.30 2014/03/19 18:11:17 christos Exp $    */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.29 2014/03/16 05:20:30 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.30 2014/03/19 18:11:17 christos Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ptm.h"
@@ -381,7 +381,9 @@
                        goto bad;
 
                /* now, put the indices and names into struct ptmget */
-               return pty_fill_ptmget(l, newdev, cfd, sfd, data);
+               if ((error = pty_fill_ptmget(l, newdev, cfd, sfd, data)) != 0)
+                       goto bad2;
+               return 0;
        default:
 #ifdef COMPAT_60
                error = compat_60_ptmioctl(dev, cmd, data, flag, l);
@@ -391,6 +393,11 @@
                DPRINTF(("ptmioctl EINVAL\n"));
                return EINVAL;
        }
+bad2:
+       fp = fd_getfile(sfd);
+       if (fp != NULL) {
+               fd_close(sfd);
+       }
  bad:
        fp = fd_getfile(cfd);
        if (fp != NULL) {



Home | Main Index | Thread Index | Old Index