aboutsummaryrefslogtreecommitdiff
path: root/lib/mount_bsd.c
diff options
context:
space:
mode:
authorGravatar Miklos Szeredi <mszeredi@suse.cz>2013-06-20 11:43:02 +0200
committerGravatar Miklos Szeredi <mszeredi@suse.cz>2013-06-20 11:43:02 +0200
commitaf57c73304b8a23c6ca0e1aebf4ce49071ac784a (patch)
tree9ff233b9701a15ee9050d7b7237e9c4bc8164d0f /lib/mount_bsd.c
parent787fc5195b95c393e2bf6fb440a488c972c94fe4 (diff)
libfuse: fix multiple close of device fd
- fuse_kern_unmount closes handle (e.g. 19) - a thread in my process opens a file - the OS assigns newly freed handle (i.e. 19) - fuse_kern_chan_destroy closes the same handle (i.e. 19) - a thread in my process opens another file - the OS assigns newly freed handle (i.e. 19) - * MAYHEM * Reported by Dan Greenfield
Diffstat (limited to 'lib/mount_bsd.c')
-rw-r--r--lib/mount_bsd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/mount_bsd.c b/lib/mount_bsd.c
index 9ee74fb..36c5a2b 100644
--- a/lib/mount_bsd.c
+++ b/lib/mount_bsd.c
@@ -228,18 +228,21 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
(void)mountpoint;
if (fstat(fd, &sbuf) == -1)
- return;
+ goto out;
devname_r(sbuf.st_rdev, S_IFCHR, dev, 128);
if (strncmp(dev, "fuse", 4))
- return;
+ goto out;
strtol(dev + 4, &ep, 10);
if (*ep != '\0')
- return;
+ goto out;
do_unmount(dev, fd);
+
+out:
+ close(fd);
}
/* Check if kernel is doing init in background */