From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660AbbCTDUD (ORCPT ); Thu, 19 Mar 2015 23:20:03 -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 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.3.3