mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 3/7] dma: apbh: fix out-of-bounds write on 64-bit SoCs
Date: Wed,  7 Oct 2020 11:50:54 +0200	[thread overview]
Message-ID: <20201007095058.22950-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20201007095058.22950-1-a.fatoum@pengutronix.de>

i.MX8 MM & MN are both ARM64 SoCs with a device compatible
with "fsl,imx28-dma-apbh". Probing the barebox device driver on these
SoCs would invoke undefined behavior however, because of an
errant cast. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/dma/apbh_dma.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index 3bee89f78b85..0e4961f6cbde 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -50,6 +50,7 @@
 static struct mxs_dma_chan mxs_dma_channels[MXS_MAX_DMA_CHANNELS];
 
 enum mxs_dma_id {
+	UNKNOWN_DMA_ID,
 	IMX23_DMA,
 	IMX28_DMA,
 };
@@ -596,9 +597,9 @@ static int apbh_dma_probe(struct device_d *dev)
 	enum mxs_dma_id id;
 	int ret, channel;
 
-	ret = dev_get_drvdata(dev, (const void **)&id);
-	if (ret)
-		return ret;
+	id = (enum mxs_dma_id)device_get_match_data(dev);
+	if (id == UNKNOWN_DMA_ID)
+		return -ENODEV;
 
 	apbh_dma = apbh = xzalloc(sizeof(*apbh));
 	iores = dev_request_mem_resource(dev, 0);
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-10-07  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  9:50 [PATCH v2 1/7] driver: introduce less error-prone dev_get_drvdata alternative Ahmad Fatoum
2020-10-07  9:50 ` [PATCH v2 2/7] led: pca955x: fix probing from device tree Ahmad Fatoum
2020-10-07  9:50 ` Ahmad Fatoum [this message]
2020-10-07  9:50 ` [PATCH v2 4/7] aiodev: lm75: fix out-of-bounds write on 64-bit SoCs Ahmad Fatoum
2020-10-07  9:50 ` [PATCH v2 5/7] mtd: nand-mxs: " Ahmad Fatoum
2020-10-07  9:50 ` [PATCH v2 6/7] video: imx-hdmi: fix dev_get_drvdata misuse Ahmad Fatoum
2020-10-07  9:50 ` [PATCH v2 7/7] driver: migrate some from dev_get_drvdata to device_get_match_data Ahmad Fatoum
2020-10-09  6:48 ` [PATCH v2 1/7] driver: introduce less error-prone dev_get_drvdata alternative Sascha Hauer

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=20201007095058.22950-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --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