summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Gu <ustc.gu@gmail.com>2026-03-02 16:47:12 +0300
committerUlf Hansson <ulf.hansson@linaro.org>2026-03-09 16:03:24 +0300
commit670f524faedccb1749beeb445c833ecae8c7409b (patch)
tree715dfbfa98a64a7fad4aa554e7938a19ad9b4426
parent824254f3c2518fb24e5d7aad1d9651f87f24ff2c (diff)
downloadlinux-670f524faedccb1749beeb445c833ecae8c7409b.tar.xz
mmc: sdhci-of-bst: Fix memory leak in sdhci_bst_alloc_bounce_buffer()
In sdhci_bst_alloc_bounce_buffer(), if dma_alloc_coherent() fails, the function immediately returns -ENOMEM without releasing the reserved memory, which results in a memory leak. Add the missing of_reserved_mem_device_release() call before returning -ENOMEM to properly clean up the reserved memory. Fixes: 695824f45629 ("mmc: sdhci: add Black Sesame Technologies BST C1200 controller driver") Signed-off-by: Felix Gu <ustc.gu@gmail.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/sdhci-of-bst.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci-of-bst.c b/drivers/mmc/host/sdhci-of-bst.c
index c124990a64f4..f8d3df715e1a 100644
--- a/drivers/mmc/host/sdhci-of-bst.c
+++ b/drivers/mmc/host/sdhci-of-bst.c
@@ -425,8 +425,10 @@ static int sdhci_bst_alloc_bounce_buffer(struct sdhci_host *host)
host->bounce_buffer = dma_alloc_coherent(mmc_dev(mmc), bounce_size,
&host->bounce_addr, GFP_KERNEL);
- if (!host->bounce_buffer)
+ if (!host->bounce_buffer) {
+ of_reserved_mem_device_release(mmc_dev(mmc));
return -ENOMEM;
+ }
host->bounce_buffer_size = bounce_size;