aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mount.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/mount.c
parent44088bc7fbe7c9234c090756dbf10742b1a281b1 (diff)
downloadandroid_external_fuse-ddfd2d44a6eab79c722f4b5785efdbcccb9c4d35.tar.gz
android_external_fuse-ddfd2d44a6eab79c722f4b5785efdbcccb9c4d35.tar.bz2
android_external_fuse-ddfd2d44a6eab79c722f4b5785efdbcccb9c4d35.zip
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.c')
-rw-r--r--lib/mount.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/mount.c b/lib/mount.c
index 6a9da9e..0f767c8 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -300,14 +300,18 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
pfd.fd = fd;
pfd.events = 0;
res = poll(&pfd, 1, 0);
+
+ /* Need to close file descriptor, otherwise synchronous umount
+ would recurse into filesystem, and deadlock.
+
+ Caller expects fuse_kern_unmount to close the fd, so close it
+ anyway. */
+ close(fd);
+
/* If file poll returns POLLERR on the device file descriptor,
then the filesystem is already unmounted */
if (res == 1 && (pfd.revents & POLLERR))
return;
-
- /* Need to close file descriptor, otherwise synchronous umount
- would recurse into filesystem, and deadlock */
- close(fd);
}
if (geteuid() == 0) {