]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mtd: nand: pxa3xx: Pass valid dev to dev_err()
authorChris Packham <judge.packham@gmail.com>
Thu, 18 Dec 2025 22:59:34 +0000 (11:59 +1300)
committerStefan Roese <stefan.roese@mailbox.org>
Wed, 10 Jun 2026 09:23:26 +0000 (11:23 +0200)
info->controller.active is not initialised so the dev_err() call ends up
dereferencing a null pointer causing a crash instead of outputting the
error. Add a dev member to struct pxa3xx_nand_info and use that instead
of info->controller.active->mtd.dev.

Fixes: 661c98121d49 ("mtd: nand: pxa3xx: Fix not calling dev_xxx with a device")
Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <stefan.roese@mailbox.org>
drivers/mtd/nand/raw/pxa3xx_nand.c

index 7324dc72e0a61023c30068ab5a5c0ce1c2fd4a30..ef01d48acc0dc98036d25703a91a80ed36d5cf48 100644 (file)
@@ -184,6 +184,7 @@ struct pxa3xx_nand_host {
 struct pxa3xx_nand_info {
        struct nand_hw_control  controller;
        struct pxa3xx_nand_platform_data *pdata;
+       struct udevice *dev;
 
        struct clk              *clk;
        void __iomem            *mmio_base;
@@ -585,8 +586,7 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
                        ts = get_timer(0);
                        while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
                                if (get_timer(ts) > TIMEOUT_DRAIN_FIFO) {
-                                       dev_err(info->controller.active->mtd.dev,
-                                               "Timeout on RDDREQ while draining the FIFO\n");
+                                       dev_err(info->dev, "Timeout on RDDREQ while draining the FIFO\n");
                                        return;
                                }
                        }
@@ -638,8 +638,7 @@ static void handle_data_pio(struct pxa3xx_nand_info *info)
                                   DIV_ROUND_UP(info->step_spare_size, 4));
                break;
        default:
-               dev_err(info->controller.active->mtd.dev,
-                       "%s: invalid state %d\n", __func__, info->state);
+               dev_err(info->dev, "%s: invalid state %d\n", __func__, info->state);
                BUG();
        }
 
@@ -1557,8 +1556,7 @@ static int pxa_ecc_init(struct pxa3xx_nand_info *info,
                ecc->size = 512;
 
        if (ecc_stepsize != 512 || !(nfc_layouts[i].strength)) {
-               dev_err(info->controller.active->mtd.dev,
-                       "ECC strength %d at page size %d is not supported\n",
+               dev_err(info->dev, "ECC strength %d at page size %d is not supported\n",
                        strength, page_size);
                return -ENODEV;
        }
@@ -1799,6 +1797,7 @@ static int pxa3xx_nand_probe(struct udevice *dev)
        if (ret)
                return ret;
 
+       info->dev = dev;
        pdata = info->pdata;
 
        ret = alloc_nand_resource(dev, info);