From patchwork Thu Jun 16 08:31:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 9180003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCEF760776 for ; Thu, 16 Jun 2016 08:31:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCBCC27D45 for ; Thu, 16 Jun 2016 08:31:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C16FB2804C; Thu, 16 Jun 2016 08:31:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7427027D45 for ; Thu, 16 Jun 2016 08:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751690AbcFPIbP (ORCPT ); Thu, 16 Jun 2016 04:31:15 -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 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 698302074A; Thu, 16 Jun 2016 04:31:12 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Thu, 16 Jun 2016 04:31:12 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=themaw.net; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=7lZ d8zd94c9eHGfex7SozqQkXz4=; b=bKuWzCKg9Hdg+3d1Qb2o/TJGDY3DgLJKz38 7uD7FwZDamq3v7fnf4NUddZz2YkfTzn5VvqlkiNAtERom190Iu5u3O5qiPw1jfM5 RmssK2dKIVVkC9bVlgNcuHrAfXSTmmuVXad4JNnN6Eoa5I419hohKpHODczPoPT9 RrG8fHhw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=7lZd8zd94c9eHGfex7SozqQkXz4=; b=EHO71 1nxVxlxrg9gqzNJZYTZ+kW+xb4WuhpU/TYjjynwjrPRwUyrIzpKAzWONh/H9KFb2 dJnN82TiQkkRPkZ3yex+WxlrDk5CHLGw7RqeJq2Wchvvj+jepdZUANkLjlibzgN7 tdqNcD3S+DqF+WBbrz5xBXPi8P0g+j0lfSljEQ= X-Sasl-enc: uuMuxQRaxWdw2eGmZepMyQwPZTbFPHwyNDw2zq5RwTRv 1466065871 Received: from pluto.themaw.net (203-59-133-216.dyn.iinet.net.au [203.59.133.216]) by mail.messagingengine.com (Postfix) with ESMTPA id C9E70CC01D; Thu, 16 Jun 2016 04:31:11 -0400 (EDT) Received: from pluto.themaw.net (localhost [127.0.0.1]) by pluto.themaw.net (Postfix) with ESMTP id 581ADA0067; Thu, 16 Jun 2016 16:31:08 +0800 (AWST) 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 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);