[PATCH 1/2] MTD: check for valid pdata inside plat_nand
John Crispin
blogic at openwrt.org
Sun Jul 22 02:59:57 EDT 2012
If plat_nand loads and the platform_data is not properly set it will segfault.
Signed-off-by: John Crispin <blogic at openwrt.org>
Acked-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
Cc: linux-mtd at lists.infradead.org
---
I am seeing this when plat_nand is referenced inside my DT file but
CONFIG_MTD_NAND_XWAY is not selected, resulting in platform_data not being
populated with valid data.
---
drivers/mtd/nand/plat_nand.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 1bcb520..a47ee68 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;
--
1.7.9.1
More information about the linux-mtd
mailing list