Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7025d9ad authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Linus Torvalds
Browse files

[PATCH] fuse: fix fuse_dev_poll() return value



fuse_dev_poll() returned an error value instead of a poll mask.  Luckily (or
unluckily) -ENODEV does contain the POLLERR bit.

There's also a race if filesystem is unmounted between fuse_get_conn() and
spin_lock(), in which case this event will be missed by poll().

Signed-off-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d3406ffa
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -804,16 +804,17 @@ static ssize_t fuse_dev_write(struct file *file, const char __user *buf,

static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
{
	struct fuse_conn *fc = fuse_get_conn(file);
	unsigned mask = POLLOUT | POLLWRNORM;

	struct fuse_conn *fc = fuse_get_conn(file);
	if (!fc)
		return -ENODEV;
		return POLLERR;

	poll_wait(file, &fc->waitq, wait);

	spin_lock(&fuse_lock);
	if (!list_empty(&fc->pending))
	if (!fc->connected)
		mask = POLLERR;
	else if (!list_empty(&fc->pending))
		mask |= POLLIN | POLLRDNORM;
	spin_unlock(&fuse_lock);