[bug report] mtd: rawnand: lpx32xx: Request DMA channels using DT entries

Piotr Wojtaszczyk piotr.wojtaszczyk at timesys.com
Fri Jul 5 02:45:13 PDT 2024


On Thu, Jul 4, 2024 at 5:21 PM Dan Carpenter <dan.carpenter at linaro.org> wrote:
>
> Hello Piotr Wojtaszczyk,
>
> Commit 7326d3fb1ee3 ("mtd: rawnand: lpx32xx: Request DMA channels
> using DT entries") from Jun 27, 2024 (linux-next), leads to the
> following Smatch static checker warning:
>
>         drivers/mtd/nand/raw/lpc32xx_mlc.c:609 lpc32xx_dma_setup()
>         error: 'host->dma_chan' dereferencing possible ERR_PTR()
>
> drivers/mtd/nand/raw/lpc32xx_mlc.c
>     572 static int lpc32xx_dma_setup(struct lpc32xx_nand_host *host)
>     573 {
>     574         struct mtd_info *mtd = nand_to_mtd(&host->nand_chip);
>     575         dma_cap_mask_t mask;
>     576
>     577         host->dma_chan = dma_request_chan(mtd->dev.parent, "rx-tx");
>                                  ^^^^^^^^^^^^^^^^
>
>     578         if (!host->dma_chan) {
>
> Why do we have two functions called dma_request_chan/channel()???  Confusing.
> Anyway, the _chan() function returns error pointers and the _channel() function
> returns NULL.  So this check is wrong.
>

Hi Dan,
Initial patch was replacing dma_request_channel() with dma_request_chan() to
get a dma channel using DT hint instead of platform data hint. This
could lead to
failures on machines which don't have a 'dmas' property in DT yet which I have
added recently. So the second version of the patch added back the
dma_request_channel() for backward compatibility.

Please check the bugfix patch I've sent:
"mtd: rawnand: lpx32xx: Fix dma_request_chan() error checks"


--
Piotr Wojtaszczyk
Timesys



More information about the linux-mtd mailing list