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=1796383031; b=C5NA1g/4aX5bmZWvhVnazWWZuxP7Cy3l13Mbcft9LeoPMwyvEUZ2xl8YTbQ37wuNf/rY GKEnSm/96Poh51i+4N+/lLIBke67WtShSCkXzLH2wsOl3DR2iT5nihXWW+yGBYUdBCTfI 03iX+PdTQXFkzszCjENBFHAJef7ukcNaqSOZ9wP/YhwWGuuqNcaX+Hc1OOQpTLIN/KBob LxGXcvF7qCOhn9cECEfwyC85BM2uJ11gItrftp0bvUz4fDpumfudmKeCa0LGZ94HG7kBE naNHOwPFtHPoLMI/ohvQgNgVwWyTIj2FixnvJKyL0JeuXQxdlxlaKO3a1LaXWdpQhMQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383031; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=4lALfdsRXpS6zVN7VNLQ3Tdf3S5Jx+MHoFigf3Pb/Ok=; b=JUDShjDreUYTu4hWdxeLeXpu9/YDTpCrsZtLU4UH2PcHMyPKSVUWjoDqi4f0SVWz/4NU qYRDWYtUF4kiUh5Tl9D0bihTTuyUjvoO0gmv5ij/4E0apwsL/7eiGybZgsihAja5vkM2y 6giViZW2r6v5g9WbH7JDAQkJzJSmGnQeL8JDOUhhfNjYHpu2/C3/ijNVohAqQEaxaJtab QUYVPTFTAKvkG4fDi2tMtIw/elo59hDkw6oAza6PBanaFKDFdXu/14S5L4jPGUMh3QJvT B/TZ2DNLJ2A+udA7kmyp/6zde/czBvnOuOPDgeLx5q91LW9rW543lDxsdTNu3+2fC8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dV8Hl8u9; 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 8CA56606A337; Fri, 4 Dec 2026 11:17:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dV8Hl8u9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 820591F00897; Fri, 4 Dec 2026 11:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383030; bh=4lALfdsRXpS6zVN7VNLQ3Tdf3S5Jx+MHoFigf3Pb/Ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dV8Hl8u9SRM/0I5ymxrk3CWGNrGjrSvQhscR3ZCsewxo7RZLoamQ0S8qoV9onmgr0 vbJRGwYTzl/P0MOgYelWymC7Pq256r6pwbIHf0Gz12Dhaa+uQyhtgfJUXADxkr0EeW uIu8a2cMIjhb23qEtjRVRLyzAzcNASyohwyK3PYg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski , Sasha Levin Subject: [PATCH 6.18 697/703] dma-pool: release CMA pages on atomic_pool_expand() error path Date: Fri, 4 Dec 2026 19:09:56 +0900 Message-ID: <20261204100646.384606004@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- kernel/dma/pool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/dma/pool.c +++ b/kernel/dma/pool.c @@ -140,7 +140,8 @@ remove_mapping: 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;