diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-22 00:22:58 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-22 00:22:58 +0000 |
commit | 9bcd80130f72ef039748e3d5e9639a9b8cf6609a (patch) | |
tree | f1d1a8af629a64813afdd7fe5893c2f12c075010 /sys | |
parent | b257ff20505962bcb41d4aedce9f2beb71d67894 (diff) |
Doh, fix a memory leak when an invalid file descriptor is passed to a
*at(2) function.
ok guenther@, thib@
Diffstat (limited to 'sys')
-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 (;;) { |