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=1796380855; b=QtXhSVlBOFrhDL6v8I/xEzuqzwyNpY3cX1oQAYP9oVeJzJ1EZt2bPPWDiXzq+IlEyojJ XUV61Fw54QsFAT2Qe6lXEwqKK8RGH/kOZUh1enfa6IoLOLmRqzCm9JCHn1aqAfZfpHzYM NKZogoS6MtS8z+hfMGlbfFLxMaBv0/ki55tZjaqRtdDV44vEPY4+daB7znmEo35XSG+EQ hdBsGogblVnqJKrH0B1+Vf31z/XPp10UQzwlwAOD2MwuXr22Zd39/hvv9zRKxuZ9wBo0p 5NwpnI7OBvM/WyqduBDYh01qlcKfGhP9c+4g9VgXzuX6QP+LIsf9n4DhDaxlEpuv+Ug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380855; 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=yT+S689TOLB4Mgr/acpgNoaEwJnmpuCDkU4Pb4+2Zx8=; b=mlFU50nz1X4VaD6QaGUPPgRI/an3XuA6ae8m/NKfPbVOxZGV/O0KNVjG/shVLRJHw6Y7 4MU/FClgqLqqKCMBZug3J+xV1BCRmm8IdzQpXT6jwUCw8VbX4H8TktXYFUmP73ThjzYqY NacTLMpCpRxqnCEGyvcvHcYDdhmb3ZoYPH7HaUoCVuJbKLVMNRXbdKW+m7kdEZSO0OlOy +Ouj+ZOi/0Vlhpi/NPP0wwFp/ypoaIIrOcmu2N/Bj7uyZ8R8igbVMpIHpT+SmsTJvBghr 6s0TkjIbAUjTCm7W3cCCVqWGNuFqwqAhWxpBaE1usG4eNUWRB9Xn6qtEllkGnGiUhyA== 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=CDpO+BgX; 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 174B7606A322; Fri, 4 Dec 2026 10:40:55 +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=CDpO+BgX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8608F1F000C2; Fri, 4 Dec 2026 10:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380854; bh=yT+S689TOLB4Mgr/acpgNoaEwJnmpuCDkU4Pb4+2Zx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CDpO+BgXRScNLvDl3j9UwR1NASCbgNEYN1+YorgTF2Iv9WH1r7uDXxzUFx9yzPqMB HD8btuP5+Jq2XbE3krwZfKuE249f/iPRZDNysVTwWj+Cp1lnA+vhuHeOA2yAHoXcAf EOm283MEnsNw2ApmIt+zpavaTnNu4jvXYFD8E/BY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski Subject: [PATCH 7.3 454/742] dma-pool: release CMA pages on atomic_pool_expand() error path Date: Fri, 4 Dec 2026 19:05:18 +0900 Message-ID: <20261204100647.223476815@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Szyprowski commit ca010d38da7bf05a4572a54c2c16d6d64a758c3a upstream. 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: 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 @@ -152,7 +152,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;