Skip to content

Commit

Permalink
[PATCH] fuse: fix fuse_dev_poll() return value
Browse files Browse the repository at this point in the history
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: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed Apr 11, 2006
1 parent d3406ff commit 7025d9a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,17 +804,18 @@ 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))
mask |= POLLIN | POLLRDNORM;
if (!fc->connected)
mask = POLLERR;
else if (!list_empty(&fc->pending))
mask |= POLLIN | POLLRDNORM;
spin_unlock(&fuse_lock);

return mask;
Expand Down

0 comments on commit 7025d9a

Please sign in to comment.