[PATCH v3] mtd: rawnand: fsmc: Add missing check after DMA map

Thomas Fourier posted 1 patch 3 months ago
drivers/mtd/nand/raw/fsmc_nand.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH v3] mtd: rawnand: fsmc: Add missing check after DMA map
Posted by Thomas Fourier 3 months ago
The DMA map functions can fail and should be tested for errors.

Fixes: 4774fb0a48aa ("mtd: nand/fsmc: Add DMA support")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/mtd/nand/raw/fsmc_nand.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index d579d5dd60d6..df61db8ce466 100644
--- a/drivers/mtd/nand/raw/fsmc_nand.c
+++ b/drivers/mtd/nand/raw/fsmc_nand.c
@@ -503,6 +503,8 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len,
 
 	dma_dev = chan->device;
 	dma_addr = dma_map_single(dma_dev->dev, buffer, len, direction);
+	if (dma_mapping_error(dma_dev->dev, dma_addr))
+		return -EINVAL;
 
 	if (direction == DMA_TO_DEVICE) {
 		dma_src = dma_addr;
-- 
2.43.0
Re: [PATCH v3] mtd: rawnand: fsmc: Add missing check after DMA map
Posted by Miquel Raynal 2 months, 1 week ago
On Mon, 07 Jul 2025 09:39:37 +0200, Thomas Fourier wrote:
> The DMA map functions can fail and should be tested for errors.
> 
> 

Applied to nand/next, thanks!

[1/1] mtd: rawnand: fsmc: Add missing check after DMA map
      commit: 7c9e7bdd663b238f32c9354938ff65d023f13daf

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