From patchwork Sun Jul 22 06:59:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 172478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C14DC2C01CC for ; Sun, 22 Jul 2012 17:06:13 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SsqA6-0001Oo-82; Sun, 22 Jul 2012 07:01:06 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Ssq9w-0001Oj-LZ for linux-mtd@merlin.infradead.org; Sun, 22 Jul 2012 07:00:57 +0000 Received: from [2a01:4f8:131:30e2::2] (helo=nbd.name) by casper.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Ssq9t-00042A-Us for linux-mtd@lists.infradead.org; Sun, 22 Jul 2012 07:00:55 +0000 From: John Crispin To: Artem Bityutskiy Subject: [PATCH 1/2] MTD: check for valid pdata inside plat_nand Date: Sun, 22 Jul 2012 08:59:57 +0200 Message-Id: <1342940398-2162-1-git-send-email-blogic@openwrt.org> X-Mailer: git-send-email 1.7.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120722_080054_229290_50637C08 X-CRM114-Status: UNSURE ( 8.97 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.3.2 on casper.infradead.org summary: Content analysis details: (-1.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS Cc: linux-mtd@lists.infradead.org, John Crispin X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If plat_nand loads and the platform_data is not properly set it will segfault. Signed-off-by: John Crispin Acked-by: Artem Bityutskiy Cc: linux-mtd@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;