]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mtd: rawnand: renesas: Add missing check after DMA map
authorThomas Fourier <fourier.thomas@gmail.com>
Wed, 2 Jul 2025 08:01:06 +0000 (10:01 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 30 Jul 2025 09:27:30 +0000 (11:27 +0200)
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>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/renesas-nand-controller.c

index 44f6603736d19bd18b53d99b21fb868df04993e5..ac8c1b80d7be969c71eda09d8f73350945626343 100644 (file)
@@ -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);