소스 검색

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 <blogic@openwrt.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
John Crispin 13 년 전
부모
커밋
da3888cb84
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      drivers/mtd/nand/plat_nand.c

+ 5 - 0
drivers/mtd/nand/plat_nand.c

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