All of lore.kernel.org
 help / color / mirror / Atom feed
From: Taesoo Kim <tsgatesv@gmail.com>
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 <tsgatesv@gmail.com>
Subject: [PATCH 1/1] fs/affs/file.c: unlock/release page on error
Date: Thu, 19 Mar 2015 23:19:46 -0400	[thread overview]
Message-ID: <1426821586-10552-1-git-send-email-tsgatesv@gmail.com> (raw)

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 <tsgatesv@gmail.com>
---
 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


             reply	other threads:[~2015-03-20  3:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20  3:19 Taesoo Kim [this message]
2015-03-20 21:13 ` [PATCH 1/1] fs/affs/file.c: unlock/release page on error Fabian Frederick
2015-03-21 17:31 Taesoo Kim
2015-03-21 19:51 ` Fabian Frederick
2015-03-21 19:51   ` Fabian Frederick
2015-03-21 20:05   ` Taesoo Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426821586-10552-1-git-send-email-tsgatesv@gmail.com \
    --to=tsgatesv@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=fabf@skynet.be \
    --cc=geert@linux-m68k.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.