From patchwork Fri Nov 9 08:34:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 1719731 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id AF87BDF264 for ; Fri, 9 Nov 2012 09:19:37 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TWkiQ-0002q1-1l; Fri, 09 Nov 2012 09:17:30 +0000 Received: from co9ehsobe004.messaging.microsoft.com ([207.46.163.27] helo=co9outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TWkiM-0002pX-RO for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2012 09:17:27 +0000 Received: from mail195-co9-R.bigfish.com (10.236.132.236) by CO9EHSOBE028.bigfish.com (10.236.130.91) with Microsoft SMTP Server id 14.1.225.23; Fri, 9 Nov 2012 09:17:17 +0000 Received: from mail195-co9 (localhost [127.0.0.1]) by mail195-co9-R.bigfish.com (Postfix) with ESMTP id 5304DC8012C; Fri, 9 Nov 2012 09:17:17 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzd6eahzz1de0h1202h1d1ah1d2ahzz8275bhz2dh2a8h668h839he5bhf0ah107ah11b5h121eh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14afh1504h1537h1155h) Received: from mail195-co9 (localhost.localdomain [127.0.0.1]) by mail195-co9 (MessageSwitch) id 1352452634236342_29268; Fri, 9 Nov 2012 09:17:14 +0000 (UTC) Received: from CO9EHSMHS032.bigfish.com (unknown [10.236.132.249]) by mail195-co9.bigfish.com (Postfix) with ESMTP id 35D7914004A; Fri, 9 Nov 2012 09:17:14 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS032.bigfish.com (10.236.130.42) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 9 Nov 2012 09:17:13 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.318.3; Fri, 9 Nov 2012 09:17:12 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id qA99HApb001918; Fri, 9 Nov 2012 02:17:11 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1013) id 02E571AE0C5; Fri, 9 Nov 2012 16:34:36 +0800 (CST) From: Frank Li To: , , , Subject: [PATCH 1/1] regulator: gpio-regulator: fix crash when no states property in dt Date: Fri, 9 Nov 2012 16:34:36 +0800 Message-ID: <1352450076-22682-1-git-send-email-Frank.Li@freescale.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-OriginatorOrg: freescale.net X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121109_041727_060838_F7E60F19 X-CRM114-Status: GOOD ( 17.14 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Frank Li X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Unable to handle kernel NULL pointer dereference at virtual address 00000004 pgd = 80004000 [00000004] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: CPU: 0 Not tainted (3.5.7+ #11) PC is at of_get_gpio_regulator_config+0x1b0/0x2e0 LR is at of_find_property+0x4c/0x9c pc : [<8022498c>] lr : [<80322d44>] psr: 60000013 sp : bf859de8 ip : bf859dc8 fp : bf859e14 r10: 805d1180 r9 : 8053e208 r8 : 00000001 r7 : 811056ec r6 : 00000000 r5 : bf8e0208 r4 : bf8f2b50 r3 : 805a7e00 r2 : 000000d0 r1 : 00000000 r0 : 00000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c53c7d Table: 1000404a DAC: 00000017 Process swapper/0 (pid: 1, stack limit = 0xbf8582f0) Stack: (0xbf859de8 to 0xbf85a000) 9de0: bf859e34 bf859df8 8010a040 00000000 bf8e0200 811056ec 9e00: 00000000 805b4d9c bf859e54 bf859e18 80404a14 802247e8 00000000 00000000 9e20: 00000000 00000000 00000000 00000000 00000000 00000000 8061f05c 805b4d9c 9e40: bf8e0208 00000000 bf859e64 bf859e58 8024bc0c 804049e0 bf859e8c bf859e68 9e60: 8024a7d8 8024bbf8 00000000 bf8e0208 805b4d9c bf8e023c 00000000 0000008d 9e80: bf859eac bf859e90 8024a9dc 8024a76c 8024a948 805b4d9c 8024a948 00000000 9ea0: bf859ed4 bf859eb0 80248f10 8024a954 bf83b458 bf8dd934 801f13e0 805b4d9c 9ec0: 805b8af8 bf8e9f00 bf859ee4 bf859ed8 8024a358 80248ec4 bf859f14 bf859ee8 9ee0: 80249f94 8024a344 804eb244 805d1180 805b4d9c 00000004 00000000 805d1180 9f00: 0000008d 805d1180 bf859f3c bf859f18 8024aefc 80249e1c 00000000 bf858000 9f20: 00000004 00000000 805d1180 0000008d bf859f4c bf859f40 8024bedc 8024ae88 9f40: bf859f5c bf859f50 805600b4 8024be9c bf859fb4 bf859f60 800086e4 805600ac 9f60: bf859fb4 bf859f70 805600a0 00000000 00000000 00000004 00000004 8053cb20 9f80: 00000000 804c9788 bf859fb4 805770a0 00000004 80577080 805d1180 0000008d 9fa0: 8053e208 805827a4 bf859ff4 bf859fb8 8053e974 800086b0 00000004 00000004 9fc0: 8053e208 8053e870 80026750 00000000 8053e870 80026750 00000013 00000000 9fe0: 00000000 00000000 00000000 bf859ff8 80026750 8053e87c 9773f7a7 ed28dffe Backtrace: [<802247dc>] (of_get_gpio_regulator_config+0x0/0x2e0) from [<80404a14>] (gpio_regulator_probe+0x40/0x2f0) r8:805b4d9c r7:00000000 r6:811056ec r5:bf8e0200 r4:00000000 [<804049d4>] (gpio_regulator_probe+0x0/0x2f0) from [<8024bc0c>] (platform_drv_probe+0x20/0x24) r7:00000000 r6:bf8e0208 r5:805b4d9c r4:8061f05c [<8024bbec>] (platform_drv_probe+0x0/0x24) from [<8024a7d8>] (driver_probe_device+0x78/0x1e8) [<8024a760>] (driver_probe_device+0x0/0x1e8) from [<8024a9dc>] (__driver_attach+0x94/0x98) r8:0000008d r7:00000000 r6:bf8e023c r5:805b4d9c r4:bf8e0208 r3:00000000 [<8024a948>] (__driver_attach+0x0/0x98) from [<80248f10>] (bus_for_each_dev+0x58/0x84) r6:00000000 r5:8024a948 r4:805b4d9c r3:8024a948 [<80248eb8>] (bus_for_each_dev+0x0/0x84) from [<8024a358>] (driver_attach+0x20/0x28) r6:bf8e9f00 r5:805b8af8 r4:805b4d9c [<8024a338>] (driver_attach+0x0/0x28) from [<80249f94>] (bus_add_driver+0x184/0x250) [<80249e10>] (bus_add_driver+0x0/0x250) from [<8024aefc>] (driver_register+0x80/0x134) [<8024ae7c>] (driver_register+0x0/0x134) from [<8024bedc>] (platform_driver_register+0x4c/0x60) r8:0000008d r7:805d1180 r6:00000000 r5:00000004 r4:bf858000 r3:00000000 [<8024be90>] (platform_driver_register+0x0/0x60) from [<805600b4>] (gpio_regulator_init+0x14/0x1c) [<805600a0>] (gpio_regulator_init+0x0/0x1c) from [<800086e4>] (do_one_initcall+0x40/0x184) [<800086a4>] (do_one_initcall+0x0/0x184) from [<8053e974>] (kernel_init+0x104/0x1c8) [<8053e870>] (kernel_init+0x0/0x1c8) from [<80026750>] (do_exit+0x0/0x7fc) Code: e3a02000 e1a00007 eb03f8db e3a020d0 (e5903004) Signed-off-by: Frank Li --- drivers/regulator/gpio-regulator.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index e467d0a..b51e757 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -183,7 +183,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) /* Fetch states. */ prop = of_find_property(np, "states", NULL); - proplen = prop->length / sizeof(int); + proplen = prop ? prop->length / sizeof(int) : 0; config->states = devm_kzalloc(dev, sizeof(struct gpio_regulator_state)