aboutsummaryrefslogtreecommitdiffstats
path: root/lib/helper.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2013-06-20 11:43:02 +0200
committerMiklos Szeredi <mszeredi@suse.cz>2013-07-01 10:06:37 +0200
commitddfd2d44a6eab79c722f4b5785efdbcccb9c4d35 (patch)
tree9d3b4d9ae8a687c97761b2200f448bf88ad2c53e /lib/helper.c
parent44088bc7fbe7c9234c090756dbf10742b1a281b1 (diff)
downloadlibfuse-ddfd2d44a6eab79c722f4b5785efdbcccb9c4d35.tar.gz
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/helper.c')
-rw-r--r--lib/helper.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/helper.c b/lib/helper.c
index ace19dd..b644012 100644
--- a/lib/helper.c
+++ b/lib/helper.c
@@ -249,10 +249,12 @@ struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
static void fuse_unmount_common(const char *mountpoint, struct fuse_chan *ch)
{
- int fd = ch ? fuse_chan_fd(ch) : -1;
- fuse_kern_unmount(mountpoint, fd);
- if (ch)
- fuse_chan_destroy(ch);
+ if (mountpoint) {
+ int fd = ch ? fuse_chan_clearfd(ch) : -1;
+ fuse_kern_unmount(mountpoint, fd);
+ if (ch)
+ fuse_chan_destroy(ch);
+ }
}
void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)