mtd: rawnand: denali_dt: error out if platform has no associated data
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 20 Dec 2019 11:31:51 +0000 (20:31 +0900)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 21 Jan 2020 19:00:33 +0000 (20:00 +0100)
denali->ecc_caps is a mandatory parameter. If it were left unset,
nand_ecc_choose_conf() would end up with NULL pointer access.

So, every compatible must be associated with proper denali_dt_data.
If of_device_get_match_data() returns NULL, let it fail immediately.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/denali_dt.c

index 8b779a8..2761879 100644 (file)
@@ -118,11 +118,12 @@ static int denali_dt_probe(struct platform_device *pdev)
        denali = &dt->controller;
 
        data = of_device_get_match_data(dev);
-       if (data) {
-               denali->revision = data->revision;
-               denali->caps = data->caps;
-               denali->ecc_caps = data->ecc_caps;
-       }
+       if (WARN_ON(!data))
+               return -EINVAL;
+
+       denali->revision = data->revision;
+       denali->caps = data->caps;
+       denali->ecc_caps = data->ecc_caps;
 
        denali->dev = dev;
        denali->irq = platform_get_irq(pdev, 0);