summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_syscalls.c
diff options
context:
space:
mode:
authorjonathan <jonathan@FreeBSD.org>2011-08-11 13:29:59 +0000
committerjonathan <jonathan@FreeBSD.org>2011-08-11 13:29:59 +0000
commit8cb2c0bf4dc41b622c3489c115dcb8b21990c0cd (patch)
tree606212c804cba4f1adfc78c83e6377c3fa186822 /sys/kern/vfs_syscalls.c
parenteb7d495d9db9e8a83ae067ec87e0675be8366adb (diff)
downloadFreeBSD-src-8cb2c0bf4dc41b622c3489c115dcb8b21990c0cd.zip
FreeBSD-src-8cb2c0bf4dc41b622c3489c115dcb8b21990c0cd.tar.gz
Only call fdclose() on successfully-opened FDs.
Since kern_openat() now uses falloc_noinstall() and finstall() separately, there are cases where we could get to cleanup code without ever creating a file descriptor. In those cases, we should not call fdclose() on FD -1. Approved by: re (kib), mentor (rwatson) Sponsored by: Google Inc
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r--sys/kern/vfs_syscalls.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 3a7ca06..7f855c0 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1116,7 +1116,8 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
* Clean up the descriptor, but only if another thread hadn't
* replaced or closed it.
*/
- fdclose(fdp, fp, indx, td);
+ if (indx != -1)
+ fdclose(fdp, fp, indx, td);
fdrop(fp, td);
if (error == ERESTART)
@@ -1185,7 +1186,8 @@ success:
bad:
VFS_UNLOCK_GIANT(vfslocked);
bad_unlocked:
- fdclose(fdp, fp, indx, td);
+ if (indx != -1)
+ fdclose(fdp, fp, indx, td);
fdrop(fp, td);
td->td_retval[0] = -1;
return (error);
OpenPOWER on IntegriCloud