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

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

Fixes: 058e0e847d ("mtd: rawnand: rockchip: NFC driver for RK3308, RK2928 and others")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
Thomas Fourier 2025-07-07 09:15:50 +02:00 committed by Miquel Raynal
parent 125100566b
commit 3b36f86dc4

View File

@ -656,9 +656,16 @@ static int rk_nfc_write_page_hwecc(struct nand_chip *chip, const u8 *buf,
dma_data = dma_map_single(nfc->dev, (void *)nfc->page_buf,
mtd->writesize, DMA_TO_DEVICE);
if (dma_mapping_error(nfc->dev, dma_data))
return -ENOMEM;
dma_oob = dma_map_single(nfc->dev, nfc->oob_buf,
ecc->steps * oob_step,
DMA_TO_DEVICE);
if (dma_mapping_error(nfc->dev, dma_oob)) {
dma_unmap_single(nfc->dev, dma_data, mtd->writesize, DMA_TO_DEVICE);
return -ENOMEM;
}
reinit_completion(&nfc->done);
writel(INT_DMA, nfc->regs + nfc->cfg->int_en_off);
@ -772,9 +779,17 @@ static int rk_nfc_read_page_hwecc(struct nand_chip *chip, u8 *buf, int oob_on,
dma_data = dma_map_single(nfc->dev, nfc->page_buf,
mtd->writesize,
DMA_FROM_DEVICE);
if (dma_mapping_error(nfc->dev, dma_data))
return -ENOMEM;
dma_oob = dma_map_single(nfc->dev, nfc->oob_buf,
ecc->steps * oob_step,
DMA_FROM_DEVICE);
if (dma_mapping_error(nfc->dev, dma_oob)) {
dma_unmap_single(nfc->dev, dma_data, mtd->writesize,
DMA_FROM_DEVICE);
return -ENOMEM;
}
/*
* The first blocks (4, 8 or 16 depending on the device)