]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:30:58 +0000 (16:30 +0200)
commit 6c4dab38431fee3d39a841d66ba6f2890b31b005 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/raw/fsmc_nand.c

index 811982da355740a58f51ca3d2b8d4583e13aec03..fe5912d31beea446f2fd807f0b48533f06f757c3 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;