mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
mtd: rawnand: rockchip: Add missing check after DMA map
[ Upstream commit 3b36f86dc47261828f96f826077131a35dd825fd ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7d0b53a6d1
commit
a01bc4245e
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user