From nobody Sun Oct 5 21:59:24 2025 Received: from venus.cs.northwestern.edu (venus.cs.northwestern.edu [129.105.2.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01B4738B for ; Tue, 29 Jul 2025 00:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=129.105.2.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753747863; cv=none; b=ss5dDoP8ydC7WS91XNLRe4tGobqNoH3i5x+0JWGWbhuEPNRv6NiiStXMr8dJU6Z6vBqcfqQM7exTAXxVAdxfEzjWeP0VSrVQqmn+o5xBV9hhWy5EsNb76X1Zu6eC9SRZZaYoHH+fh4bp1T5JUyAjBnGMhyOQq1Jt60zy0D+l0x0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753747863; c=relaxed/simple; bh=bTBaGoVcB+oGNwmqze64PMLBMQYGbnZRuCZ7LabksSU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oUkORylsWiSG/8Pd1IMsGJ8bibvAIAD2eNN8qvJFya/s49FfHG+lOhmAbZ/uj6mX674SIW10EToDZV/VaqllYUYo6bLJZK3mAJhbYUF8brRqFTfVUV2fhgoxYv/VGy8zl/qs0iqZATvntv/B2KH6Ucx7rb8UX1GgFpm5M1BULfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=northwestern.edu; spf=fail smtp.mailfrom=northwestern.edu; arc=none smtp.client-ip=129.105.2.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=northwestern.edu Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=northwestern.edu Received: from venus.cs.northwestern.edu (localhost [127.0.0.1]) by venus.cs.northwestern.edu (Postfix) with ESMTP id 1870F181B06; Mon, 28 Jul 2025 19:05:10 -0500 (CDT) From: Zheng Yu To: Dave Kleikamp Cc: Edward Adam Davis , Rand Deeb , Jeongjun Park , Nihar Chaithanya , Zheng Yu , Vasiliy Kovalev , jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] jfs: fix metapage reference count leak in dbAllocCtl Date: Tue, 29 Jul 2025 00:05:08 +0000 Message-ID: <20250729000508.3517823-1-zheng.yu@northwestern.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: 51a203470f502a64a3da8dcea51c4748e8267a6c ("jfs: fix shift-out-of-bou= nds in dbSplit") Signed-off-by: Zheng Yu --- 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 =3D (struct dmap *) mp->data; =20 - if (dp->tree.budmin < 0) + if (dp->tree.budmin < 0) { + release_metapage(mp); return -EIO; + } =20 /* try to allocate the blocks. */ --=20 2.43.0