All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	ldv-project@linuxtesting.org
Subject: Re: [PATCH] mmc: mmc_spi: add checks for dma mapping error
Date: Mon, 8 Feb 2016 16:23:39 +0100	[thread overview]
Message-ID: <CAPDyKFpc118zhWv4KFo0EHhZyu6RnPu0ot1mDWygXcKmuVQ3Cw@mail.gmail.com> (raw)
In-Reply-To: <1454715395-9462-1-git-send-email-khoroshilov@ispras.ru>

On 6 February 2016 at 00:36, Alexey Khoroshilov <khoroshilov@ispras.ru> wrote:
> There is no checks for dma mapping errors in mmc_spi.
> Tha patch fixes that and by the way it adds dma_unmap_single(ones_dma)
> that was left on a failure path mmc_spi_probe().
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Thanks, applied for fixes!

Kind regards
Uffe

> ---
>  drivers/mmc/host/mmc_spi.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> index 1c1b45ef3faf..3446097a43c0 100644
> --- a/drivers/mmc/host/mmc_spi.c
> +++ b/drivers/mmc/host/mmc_spi.c
> @@ -925,6 +925,10 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
>
>                         dma_addr = dma_map_page(dma_dev, sg_page(sg), 0,
>                                                 PAGE_SIZE, dir);
> +                       if (dma_mapping_error(dma_dev, dma_addr)) {
> +                               data->error = -EFAULT;
> +                               break;
> +                       }
>                         if (direction == DMA_TO_DEVICE)
>                                 t->tx_dma = dma_addr + sg->offset;
>                         else
> @@ -1393,10 +1397,12 @@ static int mmc_spi_probe(struct spi_device *spi)
>                 host->dma_dev = dev;
>                 host->ones_dma = dma_map_single(dev, ones,
>                                 MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
> +               if (dma_mapping_error(dev, host->ones_dma))
> +                       goto fail_ones_dma;
>                 host->data_dma = dma_map_single(dev, host->data,
>                                 sizeof(*host->data), DMA_BIDIRECTIONAL);
> -
> -               /* REVISIT in theory those map operations can fail... */
> +               if (dma_mapping_error(dev, host->data_dma))
> +                       goto fail_data_dma;
>
>                 dma_sync_single_for_cpu(host->dma_dev,
>                                 host->data_dma, sizeof(*host->data),
> @@ -1462,6 +1468,11 @@ fail_glue_init:
>         if (host->dma_dev)
>                 dma_unmap_single(host->dma_dev, host->data_dma,
>                                 sizeof(*host->data), DMA_BIDIRECTIONAL);
> +fail_data_dma:
> +       if (host->dma_dev)
> +               dma_unmap_single(host->dma_dev, host->ones_dma,
> +                               MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
> +fail_ones_dma:
>         kfree(host->data);
>
>  fail_nobuf1:
> --
> 1.9.1
>

      reply	other threads:[~2016-02-08 15:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 23:36 [PATCH] mmc: mmc_spi: add checks for dma mapping error Alexey Khoroshilov
2016-02-08 15:23 ` 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=CAPDyKFpc118zhWv4KFo0EHhZyu6RnPu0ot1mDWygXcKmuVQ3Cw@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=javier@osg.samsung.com \
    --cc=khoroshilov@ispras.ru \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.