Skip to contentSkip to conversation

mtd: rawnand: renesas: Add missing check after DMA map

PATCH Applied Thomas Fourier 2 participants 2 messages Jul 2, 2025 – Jul 28, 2025

Subsystems (4)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mtd: rawnand: renesas: Add missing check after DMA map

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

Fixes d8701fe890ec ("mtd: rawnand: renesas: Add new NAND controller driver")
---
 drivers/mtd/nand/raw/renesas-nand-controller.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/mtd/nand/raw/renesas-nand-controller.c +6 -0
index 44f6603736d1..ac8c1b80d7be 100644
@@ -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);
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 3 lines · Thomas Fourier

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