From patchwork Tue May 20 11:43:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 4218511 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 53578BEEAB for ; Wed, 21 May 2014 19:23:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 764A420379 for ; Wed, 21 May 2014 19:23:35 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) by mail.kernel.org (Postfix) with ESMTP id 79AB120166 for ; Wed, 21 May 2014 19:23:34 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [IPv6:::1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 41D613C6; Wed, 21 May 2014 19:23:34 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0EBC33C6 for ; Wed, 21 May 2014 19:23:33 +0000 (UTC) X-Greylist: delayed 00:05:01 by SQLgrey-1.7.6 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [195.130.137.89]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id E4B3E1FD42 for ; Wed, 21 May 2014 19:23:30 +0000 (UTC) Received: from ayla.of.borg ([84.193.72.141]) by laurent.telenet-ops.be with bizsmtp id 4jJT1o01632ts5g01jJT7e; Wed, 21 May 2014 21:18:28 +0200 Received: from geert (helo=localhost) by ayla.of.borg with local-esmtp (Exim 4.76) (envelope-from ) id 1WnC1z-0005CS-Oo for ltsi-dev@lists.linuxfoundation.org; Wed, 21 May 2014 21:18:27 +0200 X-Return-Path: X-Delivered-To: geert.uytterhoeven+renesas@gmail.com X-Received: by 10.64.17.199 with SMTP id q7csp25158ied; Tue, 20 May 2014 04:44:00 -0700 (PDT) X-Received: by 10.140.88.241 with SMTP id t104mr56087136qgd.29.1400586239986; Tue, 20 May 2014 04:43:59 -0700 (PDT) X-Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net. [2001:4b98:c:538::198]) by mx.google.com with ESMTPS id 2si10448522qgx.161.2014.05.20.04.43.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 20 May 2014 04:43:59 -0700 (PDT) Received-SPF: none (google.com: geert@linux-m68k.org does not designate permitted sender hosts) client-ip=2001:4b98:c:538::198; Authentication-Results: mx.google.com; spf=neutral (google.com: geert@linux-m68k.org does not designate permitted sender hosts) smtp.mail=geert@linux-m68k.org X-Received: from spool.mail.gandi.net (mspool4-d.mgt.gandi.net [10.0.21.135]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id 92010FB8CC for ; Tue, 20 May 2014 13:43:58 +0200 (CEST) X-Received: from mfilter33-d.gandi.net (mfilter33-d.gandi.net [217.70.178.164]) by spool.mail.gandi.net (Postfix) with ESMTP id 8717114222C for ; Tue, 20 May 2014 13:43:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter33-d.gandi.net X-Received: from spool.mail.gandi.net ([10.0.21.135]) by mfilter33-d.gandi.net (mfilter33-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id PYlazYlMcIM7 for ; Tue, 20 May 2014 13:43:57 +0200 (CEST) X-Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) by spool.mail.gandi.net (Postfix) with ESMTP id 1B4E4142261 for ; Tue, 20 May 2014 13:43:53 +0200 (CEST) X-Received: from ayla.of.borg ([84.193.72.141]) by andre.telenet-ops.be with bizsmtp id 4Bjs1o00h32ts5g01Bjs3n; Tue, 20 May 2014 13:43:53 +0200 X-Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1WmiSW-0006Dr-7c; Tue, 20 May 2014 13:43:52 +0200 From: Geert Uytterhoeven To: Soren Brinkmann , Daniel Sangorrin , Yoshitake Kobayashi Date: Tue, 20 May 2014 13:43:48 +0200 Message-Id: <1400586228-23880-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.7.9.5 ReSent-Date: Wed, 21 May 2014 21:18:24 +0200 (CEST) ReSent-From: Geert Uytterhoeven ReSent-To: ltsi-dev@lists.linuxfoundation.org ReSent-Subject: [PATCH ltsi-3.10.31] mtd: m25p80: Fix crash in m25p_probe() ReSent-Message-ID: ReSent-User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org Cc: ltsi-dev@lists.linuxfoundation.org, Geert Uytterhoeven Subject: [LTSI-dev] [PATCH ltsi-3.10.31] mtd: m25p80: Fix crash in m25p_probe() X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP If of_property_read_string() fails, comp_str will be uninitialized, causing crashes: Unable to handle kernel NULL pointer dereference at virtual address 0000009f ... PC is at strcmp+0xc/0x40 LR is at m25p_probe+0x410/0xa04 and Unable to handle kernel NULL pointer dereference at virtual address 00000000 ... PC is at strcmp+0xc/0x40 LR is at m25p_probe+0x6f4/0xa0c Introduced by "mtd: xilinx: merge nand flash support from xilinx repository" ([ltsi-kernel.git] / patches.zynq / 0007-mtd-xilinx-merge-nand-flash-support-from-xilinx-repo.patch) Signed-off-by: Geert Uytterhoeven --- drivers/mtd/devices/m25p80.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 3572513cb0f0..d33317d7842e 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -1243,8 +1243,8 @@ static int m25p_probe(struct spi_device *spi) const char *comp_str; u32 is_dual; np = of_get_next_parent(spi->dev.of_node); - of_property_read_string(np, "compatible", &comp_str); - if (!strcmp(comp_str, "xlnx,ps7-qspi-1.00.a")) { + if (!of_property_read_string(np, "compatible", &comp_str) && + !strcmp(comp_str, "xlnx,ps7-qspi-1.00.a")) { if (of_property_read_u32(np, "is-dual", &is_dual) < 0) { /* Default to single if prop not defined */ flash->shift = 0; @@ -1354,8 +1354,9 @@ static int m25p_probe(struct spi_device *spi) #ifdef CONFIG_OF const char *comp_str; np = of_get_next_parent(spi->dev.of_node); - of_property_read_string(np, "compatible", &comp_str); - if (!strcmp(comp_str, "xlnx,ps7-qspi-1.00.a")) { + if (!of_property_read_string(np, "compatible", + &comp_str) && + !strcmp(comp_str, "xlnx,ps7-qspi-1.00.a")) { flash->addr_width = 3; set_4byte(flash, info->jedec_id, 0); } else {