Commit 5a9294e5 authored by Andrey Vagin's avatar Andrey Vagin Committed by Linus Torvalds

autofs: don't get stuck in a loop if vfs_write() returns an error

__vfs_write() returns a negative value in a error case.

Link: http://lkml.kernel.org/r/20160616083108.6278.65815.stgit@pluto.themaw.netSigned-off-by: default avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8285027f
...@@ -66,11 +66,12 @@ static int autofs4_write(struct autofs_sb_info *sbi, ...@@ -66,11 +66,12 @@ static int autofs4_write(struct autofs_sb_info *sbi,
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
mutex_lock(&sbi->pipe_mutex); mutex_lock(&sbi->pipe_mutex);
wr = __vfs_write(file, data, bytes, &file->f_pos); while (bytes) {
while (bytes && wr) { wr = __vfs_write(file, data, bytes, &file->f_pos);
if (wr <= 0)
break;
data += wr; data += wr;
bytes -= wr; bytes -= wr;
wr = __vfs_write(file, data, bytes, &file->f_pos);
} }
mutex_unlock(&sbi->pipe_mutex); mutex_unlock(&sbi->pipe_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment