From: John Crispin Date: Sun, 22 Jul 2012 06:59:57 +0000 (+0200) Subject: mtd: check for valid pdata inside plat_nand X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=da3888cb84065a03d30b5f729b405e573bd0d66e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git mtd: check for valid pdata inside plat_nand If plat_nand loads and the platform_data is not properly set it will segfault. Signed-off-by: John Crispin Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c index 1bcb52040422..a47ee68a0cfa 100644 --- a/drivers/mtd/nand/plat_nand.c +++ b/drivers/mtd/nand/plat_nand.c @@ -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;