]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mtd: rawnand: fsmc: Add missing check after DMA map
authorThomas Fourier <fourier.thomas@gmail.com>
Mon, 7 Jul 2025 07:39:37 +0000 (09:39 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 30 Jul 2025 09:27:30 +0000 (11:27 +0200)
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>
Rule: add
Link: https://lore.kernel.org/stable/20250702065806.20983-2-fourier.thomas%40gmail.com
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/fsmc_nand.c

index d579d5dd60d66e45c6b7447e6d5830c0135fcf05..df61db8ce466593d533e617c141a8d2498b3a180 100644 (file)
@@ -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;