Skip to contentSkip to conversation

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

PATCH New [email protected] 1 participant 1 message Jun 24, 2016

lore
Share & tools
lore
#0 lore raw

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

From: Andrey Vagin <[email protected]>
Subject: autofs: don't get stuck in a loop if vfs_write() returns an error

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

---

 fs/autofs4/waitq.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/autofs4/waitq.c renamed from fs/autofs4/waitq.c~autofs-dont-stuck-in-a-loop-if-vfs_write-returns-an-error +4 -3
diff -puN fs/autofs4/waitq.c~autofs-dont-stuck-in-a-loop-if-vfs_write-returns-an-error fs/autofs4/waitq.c
@@ -66,11 +66,12 @@ static int autofs4_write(struct autofs_s
 	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);
 

_