From: Sascha Hauer <s.hauer@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] mci: imx-esdhc: Bail out if DMA address is larger than 32-bits
Date: Mon, 27 Aug 2018 08:53:56 +0200 [thread overview]
Message-ID: <20180827065356.czsutcrwoxiwysvj@pengutronix.de> (raw)
In-Reply-To: <20180824030511.23021-2-andrew.smirnov@gmail.com>
On Thu, Aug 23, 2018 at 08:05:09PM -0700, Andrey Smirnov wrote:
> On 64-bit SoCs it becomes possible to end up with a DMA buffer
> allocated in the region of memory inaccessible to ESDHC
> controller. Change the code to bail out if that happens to avoid
> silent failures.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> drivers/mci/imx-esdhc.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
> index db96a8139..f6451e204 100644
> --- a/drivers/mci/imx-esdhc.c
> +++ b/drivers/mci/imx-esdhc.c
> @@ -304,6 +304,9 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
> dma = dma_map_single(host->dev, ptr, num_bytes, dir);
> if (dma_mapping_error(host->dev, dma))
> return -EIO;
> +
> + if (dma > U32_MAX)
> + return -EFAULT;
> }
If struct device_d had a dma_mask member, it could be initialized by the
esdhc driver probe function and dma_map_single() would already fail on
addresses > 32bit without additional checks.
That's what Linux does and I think we should do the same.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-08-27 6:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 3:05 [PATCH 0/3] i.MX8 malloc pool position and 32-bit only DMA Andrey Smirnov
2018-08-24 3:05 ` [PATCH 1/3] mci: imx-esdhc: Bail out if DMA address is larger than 32-bits Andrey Smirnov
2018-08-27 6:53 ` Sascha Hauer [this message]
2018-08-27 23:33 ` Andrey Smirnov
2018-08-24 3:05 ` [PATCH 2/3] net: fec: " Andrey Smirnov
2018-08-24 3:05 ` [PATCH 3/3] ARM: start: Place malloc pool within 32-bit address space Andrey Smirnov
2018-08-27 9:06 ` Sascha Hauer
2018-08-27 23:38 ` Andrey Smirnov
2018-08-24 17:15 ` [PATCH 0/3] i.MX8 malloc pool position and 32-bit only DMA Sam Ravnborg
2018-08-27 23:32 ` Andrey Smirnov
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=20180827065356.czsutcrwoxiwysvj@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox