Commit 856db375 authored by Zheng Yu's avatar Zheng Yu Committed by Dave Kleikamp
Browse files

jfs: fix metapage reference count leak in dbAllocCtl



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.

Fixes: a5f5e469 ("jfs: fix shift-out-of-bounds in dbSplit")

Signed-off-by: default avatarZheng Yu <zheng.yu@northwestern.edu>
Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
parent b89798e7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1815,8 +1815,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.
		 */