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=1796389259; b=uZGn5r+gSuRkF67KrUqrsD+l1Q2ugPGq0ifcGKVA1zpT1Gaf6EdTuQExy8mPQE6mZQZ3 tdU3GWEdQmummgUof6d4e7cjhbshF6Fc6nGmceE4fURpjvxUu0BNw46ae6S43JSstQrXF 01Axw9wz8cgeUI33ywiTXVeeBTCHoaCXalA4e59Wfgj9/x3Hqi45srTqBB0rKuzHjdMzy D8TXhdJLNKsHKaU3gWgWfXjqGtwiYe6chhjNVGMuqa1NLFQ3JKWZSBk1jybsYO0irc5zu hrYwbkoskHrIhk6hRpDfICRxOvT3oCrKKwABp+lmAlrUeTvBMnAUD7Q/BanPKdNiBEQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389259; 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=Dy2/LXTLADJ/oa51tWAa2v5gYmMEMmgy+a0Zcof1Jys=; b=ejMnVzdvnfdqfJ6ZqjY+u2ITQjtKqqOuZ+T0tsiLjuo2qq+MqqmFvxt4ztSMUtpfLHXC ZbPg7RTDktb1n+r4de1WO9w5riTP4v0Iwz5QCfViY4fPVGgFlxkEEHEaP4vh3uVL/+NkL JEA7JXJdau6Oro+KTtGj4OXuxUHzYBI5aWw1OSnlT0SMsAZgjtZqaeBvzY0kU3S6WxoPk /g9dHZo+Xo725ee/Kfa9Mk1WwXfhuubL3GfqPmkJLhd0ebWJeZ3x+A/sM43+MGXlbap+r a6RZYosVn8i188uiO8Vr7fnf4fXzbTTQMiEeXdcqpgwFONitNQ3h6U0LJjTxe05EXNg== 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=Z5P1Lsih; 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 A02A4606A322; Fri, 4 Dec 2026 13:00:59 +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=Z5P1Lsih Received: by smtp.kernel.org (Postfix) with ESMTPSA id 798711F00931; Fri, 4 Dec 2026 13:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389259; bh=Dy2/LXTLADJ/oa51tWAa2v5gYmMEMmgy+a0Zcof1Jys=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z5P1LsihM9oYNTvAw63f6dVwOLsZTaIsBXUkackRvn4asHRmAn/KtdASArS9LmSdM hOTgRf+wY2J/7JhW+EPA53EChKWcyCe2/6PfmbSTKYW90jfGi6q72ACdv0pA0j2+Kl jg2sxkQL0ACv//XUkbVGkKdIs/FvO/jzqyKgabRE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski Subject: [PATCH 6.1 0924/1059] dma-coherent: serialize reserved memory pool initialization Date: Fri, 4 Dec 2026 19:07:35 +0900 Message-ID: <20261204100707.957971402@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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 6.1-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 @@ -333,10 +334,18 @@ int dma_init_global_coherent(phys_addr_t static struct reserved_mem *dma_reserved_default_memory __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);