From: Adrian Hunter <adrian.hunter@intel.com>
To: Felix Gu <ustc.gu@gmail.com>, Ge Gordon <gordon.ge@bst.ai>,
"BST Linux Kernel Upstream Group" <bst-upstream@bstai.top>,
Ulf Hansson <ulf.hansson@linaro.org>,
Albert Yang <yangzh0906@thundersoft.com>,
"Arnd Bergmann" <arnd@arndb.de>
Cc: <linux-arm-kernel@lists.infradead.org>,
<linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mmc: sdhci-of-bst: Fix memory leak in sdhci_bst_alloc_bounce_buffer()
Date: Mon, 2 Mar 2026 14:42:21 +0200 [thread overview]
Message-ID: <6e0e650b-d349-4a9a-9dbd-8244fb050b9e@intel.com> (raw)
In-Reply-To: <20260301-bst-v1-1-ddbc22ec3ed9@gmail.com>
On 01/03/2026 09:53, Felix Gu wrote:
> 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>
> ---
> drivers/mmc/host/sdhci-of-bst.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-bst.c b/drivers/mmc/host/sdhci-of-bst.c
> index c124990a64f4..79c945f4858e 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(host->mmc));
Please use the same expression for the device as the rest of the
function i.e. change "mmc_dev(host->mmc)" to "mmc_dev(mmc)"
> return -ENOMEM;
> + }
>
> host->bounce_buffer_size = bounce_size;
>
>
> ---
> base-commit: 3fa5e5702a82d259897bd7e209469bc06368bf31
> change-id: 20260301-bst-76bb7c6d7931
>
> Best regards,
next prev parent reply other threads:[~2026-03-02 12:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 7:53 [PATCH] mmc: sdhci-of-bst: Fix memory leak in sdhci_bst_alloc_bounce_buffer() Felix Gu
2026-03-02 12:42 ` Adrian Hunter [this message]
2026-03-02 13:26 ` Felix Gu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e0e650b-d349-4a9a-9dbd-8244fb050b9e@intel.com \
--to=adrian.hunter@intel.com \
--cc=arnd@arndb.de \
--cc=bst-upstream@bstai.top \
--cc=gordon.ge@bst.ai \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=ustc.gu@gmail.com \
--cc=yangzh0906@thundersoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox