From ddfd2d44a6eab79c722f4b5785efdbcccb9c4d35 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 20 Jun 2013 11:43:02 +0200 Subject: 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 --- lib/mount_bsd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/mount_bsd.c') diff --git a/lib/mount_bsd.c b/lib/mount_bsd.c index 62443ac..3aec3e3 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 */ -- cgit v1.2.3