Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] mtd: rawnand: cadence: use dma_map_resource for sdma address
@ 2025-02-13  7:13 Dan Carpenter
  2025-02-13  7:33 ` Rabara, Niravkumar L
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-02-13  7:13 UTC (permalink / raw)
  To: Niravkumar L Rabara; +Cc: linux-mtd

Hello Niravkumar L Rabara,

This is a semi-automatic email about new static checker warnings.

Commit d76d22b5096c ("mtd: rawnand: cadence: use dma_map_resource for
sdma address") from Feb 10, 2025, leads to the following Smatch
complaint:

    drivers/mtd/nand/raw/cadence-nand-controller.c:2982 cadence_nand_remove()
    warn: variable dereferenced before check 'cdns_ctrl->dmac' (see line 2975)

drivers/mtd/nand/raw/cadence-nand-controller.c
  2974		cadence_nand_chips_cleanup(cdns_ctrl);
  2975		dma_unmap_resource(cdns_ctrl->dmac->device->dev, cdns_ctrl->io.iova_dma,
                                   ^^^^^^^^^^^^^^^
The patch adds an unchecked dereference

  2976				   cdns_ctrl->io.size, DMA_BIDIRECTIONAL, 0);
  2977		cadence_nand_irq_cleanup(cdns_ctrl->irq, cdns_ctrl);
  2978		kfree(cdns_ctrl->buf);
  2979		dma_free_coherent(cdns_ctrl->dev, sizeof(struct cadence_nand_cdma_desc),
  2980				  cdns_ctrl->cdma_desc, cdns_ctrl->dma_cdma_desc);
  2981	
  2982		if (cdns_ctrl->dmac)
                    ^^^^^^^^^^^^^^^
But the old code assumed ->dmac could be NULL

  2983			dma_release_channel(cdns_ctrl->dmac);
  2984	}

regards,
dan carpenter

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-13  9:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13  7:13 [bug report] mtd: rawnand: cadence: use dma_map_resource for sdma address Dan Carpenter
2025-02-13  7:33 ` Rabara, Niravkumar L
2025-02-13  9:50   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox