1
0
Fork 0

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.net
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
hifive-unleashed-5.1
Andrey Vagin 2016-06-24 14:50:27 -07:00 committed by Linus Torvalds
parent 8285027fc4
commit 5a9294e5c5
1 changed files with 4 additions and 3 deletions

View File

@ -66,11 +66,12 @@ static int autofs4_write(struct autofs_sb_info *sbi,
set_fs(KERNEL_DS);
mutex_lock(&sbi->pipe_mutex);
wr = __vfs_write(file, data, bytes, &file->f_pos);
while (bytes && wr) {
while (bytes) {
wr = __vfs_write(file, data, bytes, &file->f_pos);
if (wr <= 0)
break;
data += wr;
bytes -= wr;
wr = __vfs_write(file, data, bytes, &file->f_pos);
}
mutex_unlock(&sbi->pipe_mutex);