diff options
author | 2011-07-22 00:22:57 +0000 | |
---|---|---|
committer | 2011-07-22 00:22:57 +0000 | |
commit | 2c3212d8e4899a39b836f86834cd97871df10715 (patch) | |
tree | e71238d0e52e46e2203f939bba414c6cfaf3e8f1 | |
parent | - update smtpctl.8 to reflect reality (diff) | |
download | wireguard-openbsd-2c3212d8e4899a39b836f86834cd97871df10715.tar.xz wireguard-openbsd-2c3212d8e4899a39b836f86834cd97871df10715.zip |
Doh, fix a memory leak when an invalid file descriptor is passed to a
*at(2) function.
ok guenther@, thib@
-rw-r--r-- | sys/kern/vfs_lookup.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index d860dee4fd5..777b3b2aeaa 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_lookup.c,v 1.44 2011/07/07 23:45:00 matthew Exp $ */ +/* $OpenBSD: vfs_lookup.c,v 1.45 2011/07/22 00:22:57 matthew Exp $ */ /* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */ /* @@ -174,11 +174,15 @@ namei(struct nameidata *ndp) vref(dp); } else { struct file *fp = fd_getfile(fdp, ndp->ni_dirfd); - if (fp == NULL || fp->f_type != DTYPE_VNODE) + if (fp == NULL || fp->f_type != DTYPE_VNODE) { + pool_put(&namei_pool, cnp->cn_pnbuf); return (EBADF); + } dp = (struct vnode *)fp->f_data; - if (dp->v_type != VDIR) + if (dp->v_type != VDIR) { + pool_put(&namei_pool, cnp->cn_pnbuf); return (EBADF); + } vref(dp); } for (;;) { |