Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Niravkumar L Rabara <niravkumar.l.rabara@intel.com>
Cc: linux-mtd@lists.infradead.org
Subject: [bug report] mtd: rawnand: cadence: use dma_map_resource for sdma address
Date: Thu, 13 Feb 2025 10:13:04 +0300	[thread overview]
Message-ID: <e448a22c-bada-448d-9167-7af71305130d@stanley.mountain> (raw)

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/

             reply	other threads:[~2025-02-13  7:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13  7:13 Dan Carpenter [this message]
2025-02-13  7:33 ` [bug report] mtd: rawnand: cadence: use dma_map_resource for sdma address Rabara, Niravkumar L
2025-02-13  9:50   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e448a22c-bada-448d-9167-7af71305130d@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=niravkumar.l.rabara@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox