Skip to content

Commit

Permalink
mtd: rawnand: stm32_fmc2: Fix dma_map_sg error check
Browse files Browse the repository at this point in the history
dma_map_sg return 0 on error, in case of error return -EIO.

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]>
Reviewed-by: Christophe Kerello <[email protected]>
Signed-off-by: Miquel Raynal <[email protected]>
Link: https://lore.kernel.org/linux-mtd/[email protected]
  • Loading branch information
jinpuwang authored and miquelraynal committed Sep 21, 2022
1 parent ddfa68d commit 43b81c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/mtd/nand/raw/stm32_fmc2_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,8 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,

ret = dma_map_sg(nfc->dev, nfc->dma_data_sg.sgl,
eccsteps, dma_data_dir);
if (ret < 0)
return ret;
if (!ret)
return -EIO;

desc_data = dmaengine_prep_slave_sg(dma_ch, nfc->dma_data_sg.sgl,
eccsteps, dma_transfer_dir,
Expand Down Expand Up @@ -893,8 +893,10 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,

ret = dma_map_sg(nfc->dev, nfc->dma_ecc_sg.sgl,
eccsteps, dma_data_dir);
if (ret < 0)
if (!ret) {
ret = -EIO;
goto err_unmap_data;
}

desc_ecc = dmaengine_prep_slave_sg(nfc->dma_ecc_ch,
nfc->dma_ecc_sg.sgl,
Expand Down

0 comments on commit 43b81c2

Please sign in to comment.