From patchwork Fri Mar 20 03:19:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taesoo Kim X-Patchwork-Id: 6054231 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1927A9F2A9 for ; Fri, 20 Mar 2015 03:20:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F918204FC for ; Fri, 20 Mar 2015 03:20:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6829A2050B for ; Fri, 20 Mar 2015 03:20:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751281AbbCTDUC (ORCPT ); Thu, 19 Mar 2015 23:20:02 -0400 Received: from mail-qc0-f175.google.com ([209.85.216.175]:36533 "EHLO mail-qc0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbbCTDUA (ORCPT ); Thu, 19 Mar 2015 23:20:00 -0400 Received: by qcto4 with SMTP id o4so83983548qct.3; Thu, 19 Mar 2015 20:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gdLDsfaXJmwndcyZY5VHMN+zyXCnE8siZ3F21hZkFyI=; b=pvYxQR/k99BuLr1vpdl5FCjOVIO7YL2qvNC+qg3obqISliGFEV1WUfP+7t36vpOxQN GTbm+kwqsZ4JIMW2ruIb/QfkQZu8rLkhgENEUqi4GkJGHx38BAcOTksNOtSAfdSMf7Cp N4YMW8r3BcBhtSih0nzPyaytCHJ3PdDy6/zzjSg6HQA+9nS0/M8sqqCuB9dJsV346nm8 Gp78PYehsOlt1rWQoCFJqRgt3PowU+VuCkp/Rj8VhoBVmGByiNLkNSfzvf4U24gUt8FY S4d6vVHI1e7tz2MoA5J/j8Z9pSAKfcJCCVksoWy9BKL6t80uGcndDCzKUjN6x2I5+dCR EDWQ== X-Received: by 10.55.22.213 with SMTP id 82mr110365621qkw.103.1426821599792; Thu, 19 Mar 2015 20:19:59 -0700 (PDT) Received: from skynet (z65-50-117-217.ips.direcpath.com. [65.50.117.217]) by mx.google.com with ESMTPSA id w130sm2208606qha.25.2015.03.19.20.19.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2015 20:19:58 -0700 (PDT) Received: by skynet (sSMTP sendmail emulation); Thu, 19 Mar 2015 23:19:57 -0400 From: Taesoo Kim To: akpm@linux-foundation.org, fabf@skynet.be, viro@zeniv.linux.org.uk, geert@linux-m68k.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Taesoo Kim Subject: [PATCH 1/1] fs/affs/file.c: unlock/release page on error Date: Thu, 19 Mar 2015 23:19:46 -0400 Message-Id: <1426821586-10552-1-git-send-email-tsgatesv@gmail.com> X-Mailer: git-send-email 2.3.3 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When affs_bread_ino() fails, correctly unlock the page and release the page cache with proper error value. All write_end() should unlock/release the page that was locked by write_beg(). Signed-off-by: Taesoo Kim --- fs/affs/file.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/affs/file.c b/fs/affs/file.c index d2468bf..15d07a0 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -699,8 +699,10 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, boff = tmp % bsize; if (boff) { bh = affs_bread_ino(inode, bidx, 0); - if (IS_ERR(bh)) - return PTR_ERR(bh); + if (IS_ERR(bh)) { + written = PTR_ERR(bh); + goto err; + } tmp = min(bsize - boff, to - from); BUG_ON(boff + tmp > bsize || tmp > bsize); memcpy(AFFS_DATA(bh) + boff, data + from, tmp); @@ -712,8 +714,10 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, bidx++; } else if (bidx) { bh = affs_bread_ino(inode, bidx - 1, 0); - if (IS_ERR(bh)) - return PTR_ERR(bh); + if (IS_ERR(bh)) { + written = PTR_ERR(bh); + goto err; + } } while (from + bsize <= to) { prev_bh = bh; @@ -790,6 +794,7 @@ done: if (tmp > inode->i_size) inode->i_size = AFFS_I(inode)->mmu_private = tmp; +err: unlock_page(page); page_cache_release(page);