Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: rawnand: cadence: fix DMA device NULL pointer dereference

The DMA device pointer `dma_dev` was being dereferenced before ensuring
that `cdns_ctrl->dmac` is properly initialized.

Move the assignment of `dma_dev` after successfully acquiring the DMA
channel to ensure the pointer is valid before use.

Fixes: d76d22b5096c ("mtd: rawnand: cadence: use dma_map_resource for sdma address")
Cc: stable@vger.kernel.org
Signed-off-by: Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

authored by

Niravkumar L Rabara and committed by
Miquel Raynal
5c56bf21 96313508

+2 -1
+2 -1
drivers/mtd/nand/raw/cadence-nand-controller.c
··· 2871 2871 static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl) 2872 2872 { 2873 2873 dma_cap_mask_t mask; 2874 - struct dma_device *dma_dev = cdns_ctrl->dmac->device; 2874 + struct dma_device *dma_dev; 2875 2875 int ret; 2876 2876 2877 2877 cdns_ctrl->cdma_desc = dma_alloc_coherent(cdns_ctrl->dev, ··· 2915 2915 } 2916 2916 } 2917 2917 2918 + dma_dev = cdns_ctrl->dmac->device; 2918 2919 cdns_ctrl->io.iova_dma = dma_map_resource(dma_dev->dev, cdns_ctrl->io.dma, 2919 2920 cdns_ctrl->io.size, 2920 2921 DMA_BIDIRECTIONAL, 0);