aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Wang <[email protected]>2022-08-19 08:07:47 +0200
committerMiquel Raynal <[email protected]>2022-09-21 10:38:46 +0200
commit40c9ba0dec90d72590f65d4a024b4de5cdd66294 (patch)
treea03924d493249644d9568bb63d52663d3f3cd6ce
parent43b81c2a3e6e07915151045aa13a6e8a9bd64419 (diff)
mtd: rawnand: marvell: Fix error handle regarding dma_map_sg
dma_map_sg return 0 on error, in case of error return -EIO, also add the dma_unmap_sg as rollback on the following error. Cc: Miquel Raynal <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Vignesh Raghavendra <[email protected]> Cc: Maxime Coquelin <[email protected]> Cc: Alexandre Torgue <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Christophe Kerello <[email protected]> Cc: Cai Huoqing <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
-rw-r--r--drivers/mtd/nand/raw/marvell_nand.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
index 2455a581fd70..d9f2f1d0b5ef 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -865,13 +865,19 @@ static int marvell_nfc_xfer_data_dma(struct marvell_nfc *nfc,
marvell_nfc_enable_dma(nfc);
/* Prepare the DMA transfer */
sg_init_one(&sg, nfc->dma_buf, dma_len);
- dma_map_sg(nfc->dma_chan->device->dev, &sg, 1, direction);
+ ret = dma_map_sg(nfc->dma_chan->device->dev, &sg, 1, direction);
+ if (!ret) {
+ dev_err(nfc->dev, "Could not map DMA S/G list\n");
+ return -ENXIO;
+ }
+
tx = dmaengine_prep_slave_sg(nfc->dma_chan, &sg, 1,
direction == DMA_FROM_DEVICE ?
DMA_DEV_TO_MEM : DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT);
if (!tx) {
dev_err(nfc->dev, "Could not prepare DMA S/G list\n");
+ dma_unmap_sg(nfc->dma_chan->device->dev, &sg, 1, direction);
return -ENXIO;
}