mtd: rawnand: rockchip: Add missing check after DMA map
Subsystems (3)
PATCH 1/1 mtd: rawnand: rockchip: Add missing check after DMA map
The DMA map functions can fail and should be tested for errors.
Fixes 058e0e847d54 ("mtd: rawnand: rockchip: NFC driver for RK3308, RK2928 and others")
Signed-off-by Thomas Fourier <[email protected]>
--- drivers/mtd/nand/raw/rockchip-nand-controller.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/mtd/nand/raw/rockchip-nand-controller.c +15 -0
@@ -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)
Signature · 1 line
2.43.0
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: rockchip: Add missing check after DMA map
commit: fd277532a84f4c9d9129a87e73dde6a6d9f34200
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