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=1796383794; b=xXqxeKn5wuujL6y6HEocQP628t7CZPacD9FqV7XRVFLCFmLPwC5imeczlKotwLIPbitY zVYtSXSuvJJrDZqccccPCkb+TDIaakCJ5s1B6zWfC1cO4M99XLcNEJGZsFYVEiL+2bQpT zLF4yvtb10sO0qqtNNAZYk8J19PvtF8W/ciLxOz5rVHNcm+mXuqqSsD8CAQx/kLldJ/ZT yBvHJ77VdejCDbvU/jBHehaUD5t0WzBgi9ckDOs9G25/r5EMS6QjClujDXhCVLXsFhGFk SxKrKtJyAeetSIai1mWGO8qyBTZkU7xmdE7mVd4QwxWWonvysxIzd5UjgYNi4FINY3A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383794; 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=l0hbeca+UKAXzasI5ytLelO8vl6Wlv2nNra27cApxYc=; b=0srgPDWsGpT732QMNeFDGdHIgVLXeBVHPyyuHFGcj282N3aZGfXqG8Rq0AeAKCnEf6Q3 rDs2FBYiHMr7QCTEU+dQ3IFEsLV+csdCMWl4S2eE8tGEcsQtISvu7mnIBRTZv8QjX6aY+ cJVNLYia6Jci2CzPXIhwcmtxuFpaHSlBUhqXs/G43+0IahsmkPwXnTnGhww9o3HUSLJze FB1R4V0iTz8oiSeGpv3+fu7utYvgyWtN8okBLzm0idtlB6/gHQO/poPjwYmQTpQ3LM5Rz YEzFIO9nknCrqvsGsMoRIybJ9tqRcJUGbDfBEaA4NCLSUxhmWsUDs8ndIpieSzEezjA== 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=OhwgaONn; 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 D2640606A691; Fri, 4 Dec 2026 11:29:54 +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=OhwgaONn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44E961F00937; Fri, 4 Dec 2026 11:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383794; bh=l0hbeca+UKAXzasI5ytLelO8vl6Wlv2nNra27cApxYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OhwgaONnqujI0vZzMChLBUFUZOA7ah4txED2oJB/JD5Q1MYU7508YWjIvqRVizZbr WSBjQAbyg7A/rPg/zbQ/YKcgnViuN5fYoJpwieMCC3FRIujFr8M5OuplJZA4Sb896S Ry+9AltZRZIsN0GsXjJfAsKQ1MbVOLChN+DrUp2w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski Subject: [PATCH 6.12 368/555] dma-coherent: serialize reserved memory pool initialization Date: Fri, 4 Dec 2026 19:06:51 +0900 Message-ID: <20261204100623.980685403@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Szyprowski commit 494f40ffabcdc8d9fa4012b2c972690f25a0a40f upstream. Multiple devices can share the same "shared-dma-pool" reserved memory region, in which case the dma_coherent_mem structure is created by the first device attached to it and stored in rmem->priv. To avoid the potential race, serialize the check and initialization of rmem->priv with a mutex. Fixes: 7bfa5ab6fa1b ("drivers: dma-coherent: add initialization from device tree") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20261026095423.966856-2-m.szyprowski@samsung.com Signed-off-by: Marek Szyprowski Signed-off-by: Greg Kroah-Hartman --- kernel/dma/coherent.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/kernel/dma/coherent.c +++ b/kernel/dma/coherent.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -334,10 +335,18 @@ static phys_addr_t dma_reserved_default_ static phys_addr_t dma_reserved_default_memory_size __initdata; #endif +static DEFINE_MUTEX(rmem_dma_mutex); + static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) { - struct dma_coherent_mem *mem = rmem->priv; + struct dma_coherent_mem *mem; + /* + * Multiple devices can share the same pool and may be probed + * concurrently, so serialize the initialization of rmem->priv. + */ + guard(mutex)(&rmem_dma_mutex); + mem = rmem->priv; if (!mem) { mem = dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, true);