Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757882AbcDAFMw (ORCPT ); Fri, 1 Apr 2016 01:12:52 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:33985 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752912AbcDAFMv (ORCPT ); Fri, 1 Apr 2016 01:12:51 -0400 From: Andrey Vagin To: Ian Kent Cc: autofs@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Vagin Subject: [PATCH] autofs: don't stuck in a loop if vfs_write returns an error Date: Thu, 31 Mar 2016 22:12:38 -0700 Message-Id: <1459487558-21258-1-git-send-email-avagin@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 835 Lines: 32 From: Andrey Vagin __vfs_write() returns a negative value in a error case. Cc: Ian Kent Signed-off-by: Andrey Vagin --- fs/autofs4/waitq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c index 0146d91..631f155 100644 --- a/fs/autofs4/waitq.c +++ b/fs/autofs4/waitq.c @@ -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); -- 2.5.0