public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: rawnand: renesas: Add missing check after DMA map
@ 2025-07-02  8:01 Thomas Fourier
  2025-07-28 10:17 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Fourier @ 2025-07-02  8:01 UTC (permalink / raw)
  Cc: Thomas Fourier, stable, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Wolfram Sang, linux-mtd, linux-renesas-soc,
	linux-kernel

The DMA map functions can fail and should be tested for errors.

Fixes: d8701fe890ec ("mtd: rawnand: renesas: Add new NAND controller driver")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/mtd/nand/raw/renesas-nand-controller.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/nand/raw/renesas-nand-controller.c b/drivers/mtd/nand/raw/renesas-nand-controller.c
index 44f6603736d1..ac8c1b80d7be 100644
--- a/drivers/mtd/nand/raw/renesas-nand-controller.c
+++ b/drivers/mtd/nand/raw/renesas-nand-controller.c
@@ -426,6 +426,9 @@ static int rnandc_read_page_hw_ecc(struct nand_chip *chip, u8 *buf,
 	/* Configure DMA */
 	dma_addr = dma_map_single(rnandc->dev, rnandc->buf, mtd->writesize,
 				  DMA_FROM_DEVICE);
+	if (dma_mapping_error(rnandc->dev, dma_addr))
+		return -ENOMEM;
+
 	writel(dma_addr, rnandc->regs + DMA_ADDR_LOW_REG);
 	writel(mtd->writesize, rnandc->regs + DMA_CNT_REG);
 	writel(DMA_TLVL_MAX, rnandc->regs + DMA_TLVL_REG);
@@ -606,6 +609,9 @@ static int rnandc_write_page_hw_ecc(struct nand_chip *chip, const u8 *buf,
 	/* Configure DMA */
 	dma_addr = dma_map_single(rnandc->dev, (void *)rnandc->buf, mtd->writesize,
 				  DMA_TO_DEVICE);
+	if (dma_mapping_error(rnandc->dev, dma_addr))
+		return -ENOMEM;
+
 	writel(dma_addr, rnandc->regs + DMA_ADDR_LOW_REG);
 	writel(mtd->writesize, rnandc->regs + DMA_CNT_REG);
 	writel(DMA_TLVL_MAX, rnandc->regs + DMA_TLVL_REG);
-- 
2.43.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mtd: rawnand: renesas: Add missing check after DMA map
  2025-07-02  8:01 [PATCH v2] mtd: rawnand: renesas: Add missing check after DMA map Thomas Fourier
@ 2025-07-28 10:17 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2025-07-28 10:17 UTC (permalink / raw)
  To: Thomas Fourier
  Cc: stable, Richard Weinberger, Vignesh Raghavendra, Wolfram Sang,
	linux-mtd, linux-renesas-soc, linux-kernel

On Wed, 02 Jul 2025 10:01:06 +0200, Thomas Fourier wrote:
> The DMA map functions can fail and should be tested for errors.
> 
> 

Applied to nand/next, thanks!

[1/1] mtd: rawnand: renesas: Add missing check after DMA map
      commit: 1257e75e62c363ff4e857a49fd5c4b1ca2b2b166

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-28 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02  8:01 [PATCH v2] mtd: rawnand: renesas: Add missing check after DMA map Thomas Fourier
2025-07-28 10:17 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox