Skip to content

Commit 79e441e

Browse files
Thomas-fouriermiquelraynal
authored andcommitted
mtd: rawnand: renesas: Add missing check after DMA map
The DMA map functions can fail and should be tested for errors. Fixes: d8701fe ("mtd: rawnand: renesas: Add new NAND controller driver") Cc: [email protected] Signed-off-by: Thomas Fourier <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent fdfb040 commit 79e441e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/mtd/nand/raw/renesas-nand-controller.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ static int rnandc_read_page_hw_ecc(struct nand_chip *chip, u8 *buf,
426426
/* Configure DMA */
427427
dma_addr = dma_map_single(rnandc->dev, rnandc->buf, mtd->writesize,
428428
DMA_FROM_DEVICE);
429+
if (dma_mapping_error(rnandc->dev, dma_addr))
430+
return -ENOMEM;
431+
429432
writel(dma_addr, rnandc->regs + DMA_ADDR_LOW_REG);
430433
writel(mtd->writesize, rnandc->regs + DMA_CNT_REG);
431434
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,
606609
/* Configure DMA */
607610
dma_addr = dma_map_single(rnandc->dev, (void *)rnandc->buf, mtd->writesize,
608611
DMA_TO_DEVICE);
612+
if (dma_mapping_error(rnandc->dev, dma_addr))
613+
return -ENOMEM;
614+
609615
writel(dma_addr, rnandc->regs + DMA_ADDR_LOW_REG);
610616
writel(mtd->writesize, rnandc->regs + DMA_CNT_REG);
611617
writel(DMA_TLVL_MAX, rnandc->regs + DMA_TLVL_REG);

0 commit comments

Comments
 (0)