mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
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: d76d22b509 ("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>
This commit is contained in:
parent
9631350885
commit
5c56bf214a
|
|
@ -2871,7 +2871,7 @@ cadence_nand_irq_cleanup(int irqnum, struct cdns_nand_ctrl *cdns_ctrl)
|
|||
static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
|
||||
{
|
||||
dma_cap_mask_t mask;
|
||||
struct dma_device *dma_dev = cdns_ctrl->dmac->device;
|
||||
struct dma_device *dma_dev;
|
||||
int ret;
|
||||
|
||||
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)
|
|||
}
|
||||
}
|
||||
|
||||
dma_dev = cdns_ctrl->dmac->device;
|
||||
cdns_ctrl->io.iova_dma = dma_map_resource(dma_dev->dev, cdns_ctrl->io.dma,
|
||||
cdns_ctrl->io.size,
|
||||
DMA_BIDIRECTIONAL, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user