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 28E423D7D80; Thu, 20 Aug 2026 16:29:29 +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=1787243370; cv=none; b=n6gBvkT2pUKJzg5QgVG1CgBH3D4WlaNlSOWpLp5UyNMGDdj10Bdzhkt/78gdbQjmNHsGIdGN7sFv+sM71N+QjemalXl6P1/jwNGbd7f6ZuphJvA8LjuBGinRZH9wqTqmnFnTVYXyM4nbgo18W9Dier+I7pUQHasbfRXArJs7INM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787243370; c=relaxed/simple; bh=2/nZKcuvoS3V6nrmmY281r0C8Z9HxMNnmSjZFYLw9pY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f3CZZpzYeudKlasapBtbzLQUxt63i5aqKLDaz7BeusUy3DTIpVHbnLk5J3hbZEjCk03gS8INsU2Zf/DzHikcbVi7qh74VA2NGcIFjL1wbdYnYENJbhGlKaAOdinyLBEjvvcY0bIbWePKkpp/oRFBnkREEi+Lh7CiL5tIwIa6bvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wMbY3idW; 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="wMbY3idW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82D011F000E9; Thu, 20 Aug 2026 16:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787243369; bh=eDGC1MVPBzfaLTNZ5nWzOtTm+xx/B1bcm378HJT+B3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wMbY3idWZImCpfisTN8FZ+4RyhrTTFEtRPhgsnNJ5bAHqXLvFqstqErnU1yZ6jjqO paySIKFZuVN4Juy1T64EGRpaDerfmE6yry8hp27MAY8ubz0/bOEiEcA7yvL471pv1Z xhCvKAJh9z1RJdi/YUrfMrIZN9Dx2qvPPAxmN6gw= 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 5.15 034/272] mmc: sdhci: unmap the bounce buffer before device release Date: Thu, 20 Aug 2026 16:53:38 +0200 Message-ID: <20260820145232.254587937@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145231.229664293@linuxfoundation.org> References: <20260820145231.229664293@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 5.15-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 @@ -4109,6 +4109,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; @@ -4163,6 +4171,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;