From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D4D3218EBA; Thu, 20 Aug 2026 17:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787246968; cv=none; b=sYGojUzm0Tzac8OFz1nBQ3wjBvfGCJEbZSf7onfrLig1G3WmAXacF7FAHz+Rlsv/q6pe98Jqeqncw+qfGkIntDLQ3r20En/6lAr1whRBYuElMUdqxwo1TMg+rK6gGNVZDCMu62VXwu4/4gxDos7K0pnFjwcSepkHxOaVsrLU7tQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787246968; c=relaxed/simple; bh=J4h/7l6hs2fHjvHK36U1MLV1/epmISaaTZUNQ/q6UWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lec9k8DOXXyi/oiD0JiaA7ZUsc/kXIuTyWm9wB+1c59WGWom5Mcpy/eQe1EOnVS4YVZGGqlib+O4+WSjCDePhBkVZgxaIBSbmWaC5Sy043fBlG3vlS9vcEh84RFSP7+QEMX17SaCDdTWdtZvSzo+FLmup5sBu9QT4LPg9BXZ5C4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sr0R5/mI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sr0R5/mI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99E3E1F000E9; Thu, 20 Aug 2026 17:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787246967; bh=etdQR9gHWBI5E99TJmEGA49Q91ndT8x8fAaXrFsmBho=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sr0R5/mIhazKf+oNG9rAiQU4y2zpZ7bhnQaL7z80Pe3g9WksAjUlS4pgvWz1Yja8l mM2fj2xMR9AdfWuno1wL3qTje+LKBp8nGe7uueWd62ldcf6C3SvFMRtw33TcAHW/Sg FesZ1U6KjwC464+BR0DO8glp29pUzB/jHh5nYi00= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ijae Kim , Myeonghun Pak , Linus Walleij , Ulf Hansson Subject: [PATCH 6.12 064/220] mmc: sdhci: unmap the bounce buffer before device release Date: Thu, 20 Aug 2026 16:54:14 +0200 Message-ID: <20260820145225.410833856@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145223.480031205@linuxfoundation.org> References: <20260820145223.480031205@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Myeonghun Pak commit 9e9f561269dff35e6f84ed21776ec37fd6360b03 upstream. sdhci_allocate_bounce_buffer() allocates its buffer with devm_kmalloc() but maps it with dma_map_single(). The buffer is therefore released by devres without the streaming DMA mapping being unmapped. Register a managed action after dma_map_single() succeeds so the mapping is removed before devres releases the buffer. The action is registered only for buffers allocated and mapped by the SDHCI core, leaving buffers provided by host drivers under their existing ownership. Fixes: bd9b902798ab ("mmc: sdhci: Implement an SDHCI-specific bounce buffer") Cc: stable@vger.kernel.org Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak Reviewed-by: Linus Walleij Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -4134,6 +4134,14 @@ void __sdhci_read_caps(struct sdhci_host } EXPORT_SYMBOL_GPL(__sdhci_read_caps); +static void sdhci_unmap_bounce_buffer(void *data) +{ + struct sdhci_host *host = data; + + dma_unmap_single(mmc_dev(host->mmc), host->bounce_addr, + host->bounce_buffer_size, DMA_BIDIRECTIONAL); +} + static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) { struct mmc_host *mmc = host->mmc; @@ -4188,6 +4196,14 @@ static void sdhci_allocate_bounce_buffer } host->bounce_buffer_size = bounce_size; + ret = devm_add_action_or_reset(mmc_dev(mmc), + sdhci_unmap_bounce_buffer, host); + if (ret) { + devm_kfree(mmc_dev(mmc), host->bounce_buffer); + host->bounce_buffer = NULL; + host->bounce_buffer_size = 0; + return; + } /* Lie about this since we're bouncing */ mmc->max_segs = max_blocks;