mtd: check for valid pdata inside plat_nand
authorJohn Crispin <blogic@openwrt.org>
Sun, 22 Jul 2012 06:59:57 +0000 (08:59 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sat, 29 Sep 2012 14:01:52 +0000 (15:01 +0100)
If plat_nand loads and the platform_data is not properly set it will segfault.

Signed-off-by: John Crispin <blogic@openwrt.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/nand/plat_nand.c

index 1bcb520404228ba2d8fe9cec1d29d9a6c535eac7..a47ee68a0cfac4467c4282f5981abb434b5ece09 100644 (file)
@@ -37,6 +37,11 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
        const char **part_types;
        int err = 0;
 
+       if (!pdata) {
+               dev_err(&pdev->dev, "platform_nand_data is missing\n");
+               return -EINVAL;
+       }
+
        if (pdata->chip.nr_chips < 1) {
                dev_err(&pdev->dev, "invalid number of chips specified\n");
                return -EINVAL;