From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796326501; b=StIotSPRoE81jcIAR1dk8oX8gr9LDGuvw20qI47jz9trxidbusDb2k4BSneiELFPyd9d JQetJmRrJTcccO+FQ+izRVJHC8nze4ldlqU0T7q8YqGZU3ipQl0t/74AxJsVmEMTilWgl KvF+BtrslYr8KAxmLBVnsKrFrfixCxFyHD5iMHa1jmeY6XtZJNeFg8O+opwQTbEsEeWpw KtiIa5pzGv3QV3+c39ltcroZGx8D0bJS+uH4HNzCnut98trOJc91nr/Do8FFzpCDhnWDQ FbOtWIvtsi0cS0hx2dP3Fm5zGdhpxCpkACrp7kqwxljC6P+LVXFU8pQClx/JfhzvZLQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326501; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=wO9olw/mDBanFy1M8JVYipSczGPR6rPyHsluX33hDdc=; b=HO/i59x8Lin0gBnzEXxlMVbG9nRUotbMSZp6Ebpc45zsj5nWIdt70IsWNbSidRadDODC wOMYQ8XuDSopmG5RDn8HyJZubnJ5SWTaEyL0W2qEMeENngg/U6uaDQpQ+d+3nJQttSwEo arzccsuJQpkfVeF2bF1+cm4LauAz4utYSiaTayBt/MUvKlAWloUyQuQjRM18AsN8C1aJ6 TYFEZBXFfP+DBXMgBqI8yxwfwfehv7ZPvEuUG/TRY/F5wpm0FpYIEOEiIu/OdhEkMjo4H UC6UbUCoSRJiUGKDQt80D5979tqwBlVQgK4nOoKibiAqhYlLLCDuGYL2DTfL6ZXP0xQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=em2zIWEZ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C128606A32F for ; Thu, 3 Dec 2026 19:35:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=em2zIWEZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 790071F000C2; Thu, 3 Dec 2026 19:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796326501; bh=wO9olw/mDBanFy1M8JVYipSczGPR6rPyHsluX33hDdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=em2zIWEZZkXa9OBTMLrvXWdKYNIbJ3ol2y6DkvHWU4yoxTtEoJJQ6/6E5kIdZcWLK lz+lNbaNQqkdXKzPwpJT7mUzoKH/JQ2llUOIdrcPNej3YpG8fJ3Yrlnr8CamI9beSb lVYvdxDvoSi9/SB/iBjpPARrpqqJ0QJuU76DnAVOL/2rlKDHjn9+1j1VuWRa1w12Zx Rl5oloKSnnv2qq1rp0OZHAsjvGp59pf6cyAKnn+9+Qkr1Za0ZvIx7uyRPvedW4cGnm FIkcpWVby01zansCeLXgP435q4ypRaj7UmbO2FNQLc7Tfrr4nb9cncT4Wn6lPftOs8 LQmz8veHuQjlQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Marek Szyprowski , Sasha Levin Subject: [PATCH 6.6.y 2/2] dma-pool: release CMA pages on atomic_pool_expand() error path Date: Thu, 3 Dec 2026 14:34:57 -0500 Message-ID: <20261203193446.653960-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203193446.653960-1-sashal@kernel.org> References: <2026120205-grumbling-salaried-cc68@gregkh> <20261203193446.653960-1-sashal@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Marek Szyprowski [ Upstream commit ca010d38da7bf05a4572a54c2c16d6d64a758c3a ] atomic_pool_expand() may allocate the pool backing pages from CMA via dma_alloc_from_contiguous(), but the error path unconditionally frees them with __free_pages(). This hands CMA pages to the buddy allocator while leaving them marked as allocated in the CMA bitmap, permanently leaking CMA capacity on every failed expansion. Try dma_release_from_contiguous() first and fall back to __free_pages() only for pages that did not come from CMA, as the code did before CMA allocation was temporarily removed from the pool. Fixes: d7e673ec2c8e ("dma-pool: Only allocate from CMA when in same memory zone") Closes: https://sashiko.dev/#/bug/linux-fdfc6e83-15e4-4980-9818-691b034397e7 Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20261026095423.966856-5-m.szyprowski@samsung.com Signed-off-by: Marek Szyprowski Signed-off-by: Sasha Levin --- kernel/dma/pool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c index 7c55405c8d0da..e3cf0f0c3db60 100644 --- a/kernel/dma/pool.c +++ b/kernel/dma/pool.c @@ -140,7 +140,8 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size, dma_common_free_remap(addr, pool_size); free_page: #endif - if (!leak_pages) + if (!leak_pages && + !dma_release_from_contiguous(NULL, page, 1 << order)) __free_pages(page, order); out: return ret; -- 2.53.0