linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chenyuan Mi <cymi20@fudan.edu.cn>
To: unlisted-recipients:; (no To-header on input)
Cc: yuanxzhang@fudan.edu.cn, Chenyuan Mi <cymi20@fudan.edu.cn>,
	Xiyu Yang <xiyuyang19@fudan.edu.cn>,
	Xin Tan <tanxin.ctf@gmail.com>, "Theodore Ts'o" <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ext4: Fix handle refcount leak in ext4_write_begin()
Date: Wed,  8 Sep 2021 15:06:40 +0800	[thread overview]
Message-ID: <20210908070640.7135-1-cymi20@fudan.edu.cn> (raw)

The reference counting issue happens when ret is zero,
the function forgets to decrease the refcount of handle
increased by ext4_journal_start().

Fix this issue by using ext4_journal_stop() to decrease
the refcount of handle.

Signed-off-by: Chenyuan Mi <cymi20@fudan.edu.cn>
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
---
 fs/ext4/inode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d18852d6029c..90c57d8e3de1 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1249,6 +1249,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 		put_page(page);
 		return ret;
 	}
+	ext4_journal_stop(handle);
 	*pagep = page;
 	return ret;
 }
-- 
2.17.1


             reply	other threads:[~2021-09-08  7:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08  7:06 Chenyuan Mi [this message]
2021-10-07 14:06 ` [PATCH] ext4: Fix handle refcount leak in ext4_write_begin() Jan Kara

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=20210908070640.7135-1-cymi20@fudan.edu.cn \
    --to=cymi20@fudan.edu.cn \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tanxin.ctf@gmail.com \
    --cc=tytso@mit.edu \
    --cc=xiyuyang19@fudan.edu.cn \
    --cc=yuanxzhang@fudan.edu.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).