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=1796380852; b=UvDZjQnYmvi7SfNpPwmwhHhNMd5Qq54iLOQnCdvyx2AKgMyjEoDe/i5OSLXNTfzefhWO mg4lq1CpHXSWMFhBTPm+uii41kTPHGlRHOckZQWdRbCn6oPC2DOCdfUWjmeTO4ykYD3FE ZdW2Rfg04/g7NTBaiZX+gJg2RjA3eWeYcV8vCltlOFsTeiF8Zl+7v2F+10t7OV4b4NoEX 8Oh8GwOw9cD1itKadffw6Fxp8201xS+7agz771ebU4KkAvgYoG1pT814wk7fMZ7ZkyDJj /+6YFmBM4wrT/l4F1Mog/gyYDifwzLMAHOfqtSgjHPAk4oYcS8geAE9BpzNLTpgTBMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380852; 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=qbdJ4baL7y1xwO7+5ImG3VqD/YjGb0YZFLUNMw2f+RU=; b=M0knFrPW6r8RIjhvEPVRnjx1SLAASZ/tMy4sUV3e6At19cZKK9cbN1qkGpy3sibrJ34r R+QOlVF1dUjWxXHZ+5NZvUt9vNDkik20xcKhthbUtK5PSyeoTOaGslsDTP91/fg1vrfEo vHJjceT1GMDfaH+bHyeLifyG9zzanlzwZC+x6uzFScTfStsq5Ml57Fqb06MiAS/tqkrNs v6nVpxP42DL8LjTfIg5uFZ9CnbIo7EoRk2fp58Lcc3AKV3AOWjgaYfMaI1pXKrRXJsj4/ gPK/OXeBHObWaW1dTaklrsuO+DoPJrmjkckpC/DrEk+cecwgY6Y96jAOcyE/Buqhofg== 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="Oh92UL/7"; 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 D1AF4606A322; Fri, 4 Dec 2026 10:40:52 +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=Oh92UL/7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44A511F000C2; Fri, 4 Dec 2026 10:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380852; bh=qbdJ4baL7y1xwO7+5ImG3VqD/YjGb0YZFLUNMw2f+RU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Oh92UL/7Zek3CYQwnlyoi0Ij2Yq4CLhSUKiTbkVE3TvjVwUecNsV+yoevM4EO0g7+ TBRQpaRc5lMCMKh5T7gV2ocXRFV9RG7s3iv487iBoC1FV/A/U6csHDw5n3jYNuUfmD RL0g9fhfa6O1rl6cxBh2ei114PrqK8pxqio9d/zg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski Subject: [PATCH 7.3 453/742] dma-coherent: serialize reserved memory pool initialization Date: Fri, 4 Dec 2026 19:05:17 +0900 Message-ID: <20261204100647.196191846@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: 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 7.3-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 @@ -335,10 +336,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);