提交 9261303a 编写于 作者: C Christoph Hellwig 提交者: Linus Torvalds

libfs: make simple attributes interruptible

Use mutex_lock_interruptible in simple_attr_read/write.
Signed-off-by: NChristoph 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 8b88b099
...@@ -634,7 +634,10 @@ ssize_t simple_attr_read(struct file *file, char __user *buf, ...@@ -634,7 +634,10 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
if (!attr->get) if (!attr->get)
return -EACCES; return -EACCES;
mutex_lock(&attr->mutex); ret = mutex_lock_interruptible(&attr->mutex);
if (ret)
return ret;
if (*ppos) { /* continued read */ if (*ppos) { /* continued read */
size = strlen(attr->get_buf); size = strlen(attr->get_buf);
} else { /* first read */ } else { /* first read */
...@@ -666,7 +669,10 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, ...@@ -666,7 +669,10 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
if (!attr->set) if (!attr->set)
return -EACCES; return -EACCES;
mutex_lock(&attr->mutex); ret = mutex_lock_interruptible(&attr->mutex);
if (ret)
return ret;
ret = -EFAULT; ret = -EFAULT;
size = min(sizeof(attr->set_buf) - 1, len); size = min(sizeof(attr->set_buf) - 1, len);
if (copy_from_user(attr->set_buf, buf, size)) if (copy_from_user(attr->set_buf, buf, size))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册