From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Zheng Yu <zheng.yu@northwestern.edu>
Cc: "eadavis@qq.com" <eadavis@qq.com>,
"rand.sec96@gmail.com" <rand.sec96@gmail.com>,
"aha310510@gmail.com" <aha310510@gmail.com>,
"niharchaithanya@gmail.com" <niharchaithanya@gmail.com>,
"kovalev@altlinux.org" <kovalev@altlinux.org>,
"jfs-discussion@lists.sourceforge.net"
<jfs-discussion@lists.sourceforge.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] jfs: fix metapage reference count leak in dbAllocCtl
Date: Tue, 29 Jul 2025 08:50:18 -0500 [thread overview]
Message-ID: <901162ef-e607-4db3-976b-33b81e322c6b@oracle.com> (raw)
In-Reply-To: <BL0PR05MB467408AB092885950559B422FF25A@BL0PR05MB4674.namprd05.prod.outlook.com>
On 7/28/25 8:22PM, Zheng Yu wrote:
> In dbAllocCtl(), read_metapage() increases the reference count of the
> metapage. However, when dp->tree.budmin < 0, the function returns -EIO
> without calling release_metapage() to decrease the reference count,
> leading to a memory leak.
>
> Add release_metapage(mp) before the error return to properly manage
> the metapage reference count and prevent the leak.
Thanks for catching this.
>
> Fixes: 51a203470f502a64a3da8dcea51c4748e8267a6c ("jfs: fix shift-out-of-bounds in dbSplit")
The correct commit is a5f5e4698f8abbb25fe4959814093fb5bfa1aa9d. I'm
guessing the above is from one of the stable branches
Also, I'm fixing up the whitespace. You have spaces instead of tabs.
Applying and testing this.
Thanks!
Shaggy
>
> Signed-off-by: Zheng Yu <zheng.yu@northwestern.edu>
> ---
> fs/jfs/jfs_dmap.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
> index 35e063c9f3a4..5a877261c3fe 100644
> --- a/fs/jfs/jfs_dmap.c
> +++ b/fs/jfs/jfs_dmap.c
> @@ -1809,8 +1809,10 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)
> return -EIO;
> dp = (struct dmap *) mp->data;
>
> - if (dp->tree.budmin < 0)
> + if (dp->tree.budmin < 0) {
> + release_metapage(mp);
> return -EIO;
> + }
>
> /* try to allocate the blocks.
> */
> --
> 2.43.0
next prev parent reply other threads:[~2025-07-29 13:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 1:22 [PATCH] jfs: fix metapage reference count leak in dbAllocCtl Zheng Yu
2025-07-29 13:50 ` Dave Kleikamp [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-07-29 0:05 Zheng Yu
2025-07-29 14:23 ` Markus Elfring
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=901162ef-e607-4db3-976b-33b81e322c6b@oracle.com \
--to=dave.kleikamp@oracle.com \
--cc=aha310510@gmail.com \
--cc=eadavis@qq.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=kovalev@altlinux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=niharchaithanya@gmail.com \
--cc=rand.sec96@gmail.com \
--cc=zheng.yu@northwestern.edu \
/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