Skip to content

Commit

Permalink
libfs: make simple attributes interruptible
Browse files Browse the repository at this point in the history
Use mutex_lock_interruptible in simple_attr_read/write.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: <stefano.brivio@polimi.it>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg KH <greg@kroah.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Christoph Hellwig authored and Linus Torvalds committed Feb 8, 2008
1 parent 8b88b09 commit 9261303
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fs/libfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,10 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
if (!attr->get)
return -EACCES;

mutex_lock(&attr->mutex);
ret = mutex_lock_interruptible(&attr->mutex);
if (ret)
return ret;

if (*ppos) { /* continued read */
size = strlen(attr->get_buf);
} else { /* first read */
Expand Down Expand Up @@ -666,7 +669,10 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
if (!attr->set)
return -EACCES;

mutex_lock(&attr->mutex);
ret = mutex_lock_interruptible(&attr->mutex);
if (ret)
return ret;

ret = -EFAULT;
size = min(sizeof(attr->set_buf) - 1, len);
if (copy_from_user(attr->set_buf, buf, size))
Expand Down

0 comments on commit 9261303

Please sign in to comment.