gen_nand: Test if nr_chips field is valid
authorMarek Vasut <marek.vasut@gmail.com>
Thu, 12 Aug 2010 02:53:55 +0000 (03:53 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 12 Aug 2010 11:17:36 +0000 (12:17 +0100)
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/nand/plat_nand.c

index 90e143e..317aff4 100644 (file)
@@ -37,6 +37,11 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
        struct resource *res;
        int err = 0;
 
+       if (pdata->chip.nr_chips < 1) {
+               dev_err(&pdev->dev, "invalid number of chips specified\n");
+               return -EINVAL;
+       }
+
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res)
                return -ENXIO;