summaryrefslogtreecommitdiff
path: root/sys/miscfs
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-01-04 10:51:12 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-01-04 10:51:12 +0000
commitd8c182527c8cbf6ab11007350397b2fc0e1633c6 (patch)
tree1390ab869cb919cc7a825a8587f7e6bacd2572e7 /sys/miscfs
parentf3a75afc057ea240499db726d5ff48a13b9e85f6 (diff)
Do a FREF/FRELE dance after calling fd_getfile().
This should be enought to prevent `fp' to disapear while sleeping in malloc(9). ok helg@
Diffstat (limited to 'sys/miscfs')
-rw-r--r--sys/miscfs/fuse/fuse_vfsops.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/miscfs/fuse/fuse_vfsops.c b/sys/miscfs/fuse/fuse_vfsops.c
index e4affbf5888..7867ff60579 100644
--- a/sys/miscfs/fuse/fuse_vfsops.c
+++ b/sys/miscfs/fuse/fuse_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_vfsops.c,v 1.30 2017/12/11 05:27:40 deraadt Exp $ */
+/* $OpenBSD: fuse_vfsops.c,v 1.31 2018/01/04 10:51:11 mpi Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -77,19 +77,25 @@ fusefs_mount(struct mount *mp, const char *path, void *data,
struct fusefs_args *args = data;
struct vnode *vp;
struct file *fp;
+ int error = 0;
if (mp->mnt_flag & MNT_UPDATE)
return (EOPNOTSUPP);
if ((fp = fd_getfile(p->p_fd, args->fd)) == NULL)
return (EBADF);
+ FREF(fp);
- if (fp->f_type != DTYPE_VNODE)
- return (EINVAL);
+ if (fp->f_type != DTYPE_VNODE) {
+ error = EINVAL;
+ goto bad;
+ }
vp = fp->f_data;
- if (vp->v_type != VCHR)
- return (EBADF);
+ if (vp->v_type != VCHR) {
+ error = EBADF;
+ goto bad;
+ }
fmp = malloc(sizeof(*fmp), M_FUSEFS, M_WAITOK | M_ZERO);
fmp->mp = mp;
@@ -117,7 +123,9 @@ fusefs_mount(struct mount *mp, const char *path, void *data,
/* cannot tsleep on mount */
fuse_device_queue_fbuf(fmp->dev, fbuf);
- return (0);
+bad:
+ FRELE(fp, p);
+ return (error);
}
int