Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: rawnand: cadence: fix possible null-ptr-deref in cadence_nand_dt_probe()

It will cause null-ptr-deref when using 'res', if platform_get_resource()
returns NULL, so move using 'res' after devm_ioremap_resource() that
will check it to avoid null-ptr-deref.
And use devm_platform_get_and_ioremap_resource() to simplify code.

Fixes: ec4ba01e894d ("mtd: rawnand: Add new Cadence NAND driver to MTD subsystem")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220426084913.4021868-1-yangyingliang@huawei.com

authored by

Yang Yingliang and committed by
Miquel Raynal
a28ed09d 3380557f

+2 -3
+2 -3
drivers/mtd/nand/raw/cadence-nand-controller.c
··· 2983 2983 if (IS_ERR(cdns_ctrl->reg)) 2984 2984 return PTR_ERR(cdns_ctrl->reg); 2985 2985 2986 - res = platform_get_resource(ofdev, IORESOURCE_MEM, 1); 2987 - cdns_ctrl->io.dma = res->start; 2988 - cdns_ctrl->io.virt = devm_ioremap_resource(&ofdev->dev, res); 2986 + cdns_ctrl->io.virt = devm_platform_get_and_ioremap_resource(ofdev, 1, &res); 2989 2987 if (IS_ERR(cdns_ctrl->io.virt)) 2990 2988 return PTR_ERR(cdns_ctrl->io.virt); 2989 + cdns_ctrl->io.dma = res->start; 2991 2990 2992 2991 dt->clk = devm_clk_get(cdns_ctrl->dev, "nf_clk"); 2993 2992 if (IS_ERR(dt->clk))