Skip to content

Commit 5c56bf2

Browse files
rabaramiquelraynal
authored andcommitted
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: d76d22b ("mtd: rawnand: cadence: use dma_map_resource for sdma address") Cc: [email protected] Signed-off-by: Niravkumar L Rabara <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 9631350 commit 5c56bf2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/mtd/nand/raw/cadence-nand-controller.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ cadence_nand_irq_cleanup(int irqnum, struct cdns_nand_ctrl *cdns_ctrl)
28712871
static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
28722872
{
28732873
dma_cap_mask_t mask;
2874-
struct dma_device *dma_dev = cdns_ctrl->dmac->device;
2874+
struct dma_device *dma_dev;
28752875
int ret;
28762876

28772877
cdns_ctrl->cdma_desc = dma_alloc_coherent(cdns_ctrl->dev,
@@ -2915,6 +2915,7 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
29152915
}
29162916
}
29172917

2918+
dma_dev = cdns_ctrl->dmac->device;
29182919
cdns_ctrl->io.iova_dma = dma_map_resource(dma_dev->dev, cdns_ctrl->io.dma,
29192920
cdns_ctrl->io.size,
29202921
DMA_BIDIRECTIONAL, 0);

0 commit comments

Comments
 (0)