From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753905AbcFPIbS (ORCPT ); Thu, 16 Jun 2016 04:31:18 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:36281 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbcFPIbN (ORCPT ); Thu, 16 Jun 2016 04:31:13 -0400 X-Sasl-enc: uuMuxQRaxWdw2eGmZepMyQwPZTbFPHwyNDw2zq5RwTRv 1466065871 Subject: [PATCH] autofs: don't stuck in a loop if vfs_write returns an error From: Ian Kent To: Andrew Morton Cc: linux-fsdevel , autofs mailing list , Andrey Vagin , Kernel Mailing List Date: Thu, 16 Jun 2016 16:31:08 +0800 Message-ID: <20160616083108.6278.65815.stgit@pluto.themaw.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Vagin __vfs_write() returns a negative value in a error case. Signed-off-by: Andrey Vagin Signed-off-by: Ian Kent --- 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);