Skip to content

Commit 60255f3

Browse files
rabaramiquelraynal
authored andcommitted
mtd: rawnand: cadence: fix unchecked dereference
Add NULL check before variable dereference to fix static checker warning. Fixes: d76d22b ("mtd: rawnand: cadence: use dma_map_resource for sdma address") Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Niravkumar L Rabara <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 4175863 commit 60255f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,8 +2972,10 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
29722972
static void cadence_nand_remove(struct cdns_nand_ctrl *cdns_ctrl)
29732973
{
29742974
cadence_nand_chips_cleanup(cdns_ctrl);
2975-
dma_unmap_resource(cdns_ctrl->dmac->device->dev, cdns_ctrl->io.iova_dma,
2976-
cdns_ctrl->io.size, DMA_BIDIRECTIONAL, 0);
2975+
if (cdns_ctrl->dmac)
2976+
dma_unmap_resource(cdns_ctrl->dmac->device->dev,
2977+
cdns_ctrl->io.iova_dma, cdns_ctrl->io.size,
2978+
DMA_BIDIRECTIONAL, 0);
29772979
cadence_nand_irq_cleanup(cdns_ctrl->irq, cdns_ctrl);
29782980
kfree(cdns_ctrl->buf);
29792981
dma_free_coherent(cdns_ctrl->dev, sizeof(struct cadence_nand_cdma_desc),

0 commit comments

Comments
 (0)