linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Takashi Iwai <tiwai@suse.de>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mmc: sdhci: Clear unused bounce buffer at DMA mmap error path
Date: Tue, 29 Jun 2021 17:08:58 +0200	[thread overview]
Message-ID: <CAPDyKFqeXERLc9=p79OVRjUfC+BM_5JqOWS+6Riuu0YRwvWOtQ@mail.gmail.com> (raw)
In-Reply-To: <20210611101948.18972-1-tiwai@suse.de>

On Fri, 11 Jun 2021 at 12:19, Takashi Iwai <tiwai@suse.de> wrote:
>
> When DMA-mapping of the bounce buffer fails, the driver tries to fall
> back, but it leaves the allocated host->bounce_buffer although its
> size is zero.  Later on, the driver checks the use of bounce buffer
> with host->bounce_buffer pointer, and it tries to use the buffer
> incorrectly, resulting in Oops.
>
> This patch clears the release the unused buffer and clears the
> bounce_buffer pointer for addressing the problem.
>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Applied for fixes, thanks!

Kind regards
Uffe


> ---
> v1->v2: correct the device pointer to mmc_dev(mmc)
>
>  drivers/mmc/host/sdhci.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index bf238ade1602..c80bc6c4ebf3 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -4072,9 +4072,13 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host)
>                                            bounce_size,
>                                            DMA_BIDIRECTIONAL);
>         ret = dma_mapping_error(mmc_dev(mmc), host->bounce_addr);
> -       if (ret)
> +       if (ret) {
> +               devm_kfree(mmc_dev(mmc), host->bounce_buffer);
> +               host->bounce_buffer = NULL;
>                 /* Again fall back to max_segs == 1 */
>                 return;
> +       }
> +
>         host->bounce_buffer_size = bounce_size;
>
>         /* Lie about this since we're bouncing */
> --
> 2.26.2
>

      reply	other threads:[~2021-06-29 15:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 10:19 [PATCH v2] mmc: sdhci: Clear unused bounce buffer at DMA mmap error path Takashi Iwai
2021-06-29 15:08 ` Ulf Hansson [this message]

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='CAPDyKFqeXERLc9=p79OVRjUfC+BM_5JqOWS+6Riuu0YRwvWOtQ@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=tiwai@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).