From patchwork Sun Nov 10 06:41:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 3165091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 28C3A9F326 for ; Sun, 10 Nov 2013 10:36:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03F6620270 for ; Sun, 10 Nov 2013 10:36:36 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2BD2D201DC for ; Sun, 10 Nov 2013 10:36:34 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VfS21-0000sM-RP; Sun, 10 Nov 2013 10:14:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VfOjw-0007cF-SZ; Sun, 10 Nov 2013 06:43:20 +0000 Received: from fallback8.mail.ru ([94.100.176.136]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VfOib-0007bu-Aa for linux-arm-kernel@lists.infradead.org; Sun, 10 Nov 2013 06:41:59 +0000 Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [94.100.177.107]) by fallback8.mail.ru (mPOP.Fallback_MX) with ESMTP id 5267A4490C00 for ; Sun, 10 Nov 2013 10:41:26 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=MAazC2uHkBSZaI0CC5J0LRKcrr4GvTcl/GPTz92cm+Q=; b=O+uPBYFeMIkVUpfUxsGJPGuhuJpNUYO/oWTzY16HJhkKOIHUOAGcKm1Te6E/UeFpLExR7ErKo6bS1wBFRuEoTXP3H4u1gw3TxHqNWlHvffaf9s+Tg3XlqXis1Q+i2UU1k+PlOrzY2flKl1HlJFhXsOJakaoS1Pjea3TbkKTerKM=; Received: from [188.134.40.128] (port=52112 helo=shc.zet) by smtp47.i.mail.ru with esmtpa (envelope-from ) id 1VfOhy-0002Tc-AD; Sun, 10 Nov 2013 10:41:18 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] mfd: mx13xxx: Fix null pointer dereference in mc13xxx_common_init Date: Sun, 10 Nov 2013 10:41:01 +0400 Message-Id: <1384065661-32400-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131110_014157_821222_D312F854 X-CRM114-Status: GOOD ( 15.53 ) X-Spam-Score: -2.0 (--) Cc: Alexander Shiyan , Lee Jones , Samuel Ortiz , Sascha Hauer X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If this driver being loaded from devicetree, the pdata is NULL. This cause kernel Oops when "fsl,mc13xxx-uses-codec" and/or "fsl,mc13xxx-uses-touch" properties is specified. mc13xxx spi0.0: mc13783: rev: 3.3, fin: 0, fab: 0, icid: 2/0 Unable to handle kernel NULL pointer dereference at virtual address 00000018 pgd = c0004000 [00000018] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT ARM CPU: 0 PID: 1 Comm: swapper Not tainted 3.12.0-next-20131105-00004-g201dd34-dirty #5 task: c7833bc0 ti: c7834000 task.ti: c7834000 PC is at mc13xxx_common_init+0x1fc/0x280 LR is at mfd_add_device+0x2a8/0x308 pc : [] lr : [] psr: 20000013 sp : c7835d38 ip : 00000002 fp : c786a160 r10: 00000000 r9 : c786a170 r8 : 00000000 r7 : c06eab74 r6 : 00000000 r5 : 00000000 r4 : c79ffa10 r3 : 00000008 r2 : 20000013 r1 : c05079c8 r0 : c79ffa10 Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 0005317f Table: a0004000 DAC: 00000017 Process swapper (pid: 1, stack limit = 0xc78341c0) Stack: (0xc7835d38 to 0xc7836000) 5d20: c0507958 c79ffa10 5d40: c791ab80 0000009b 00000000 c791ab80 c05de138 c023a998 c05a9854 c0293cf8 5d60: c0293ce0 c023a774 c023a998 00000000 c791ab80 c023a998 c79ffc00 c02393ac 5d80: c785a25c c7940e54 c791ab80 c791abb4 c791ab80 c023a4cc c791ab80 c05b2704 5da0: c791ab80 c02395e8 c791ab80 00000000 c791ab88 c0237938 00000000 c01d5ed8 5dc0: 60000013 c791ab80 c791ab80 c791ab80 00000000 c786a170 00000000 c06eaa04 5de0: c786a170 c0294d08 00000001 c79ffc00 c06eab74 c791ab80 00000000 c02953a8 5e00: c79f56a0 00000000 00000063 01312d00 00000000 c79ffc00 c79ffd78 c79ffc00 5e20: c06eaa04 00000000 c79ffd70 c0296cbc c780a840 c02978c0 00000000 c051054c 5e40: c79ffd70 c787c1f0 00000000 c0462b1c 00000000 00000002 c787c1f0 c786a170 5e60: c05b2864 c786a1a4 c05b2864 00000000 c05c5800 c0579430 00000000 c023b614 5e80: c023b5fc c786a170 c05de138 c023a774 00000000 c786a170 c05b2864 c786a1a4 5ea0: 00000000 c023a994 00000000 c05b2864 c023a908 c0239034 c7825d6c c785e610 5ec0: c05b2864 c7a0bae0 c05a9138 c02397dc c051054c c01bd2f8 c05b2864 c05b2864 5ee0: c0585094 579da752 00000000 c023ad38 00000000 00000006 c0585094 c0564a24 5f00: 0000047a 00000000 579da752 00000000 00000000 a0000053 c059b070 00000001 5f20: c06eefc9 c044c6a0 000000a7 c002cd48 c7835f5c c0036f44 c051aae4 c053d7f4 5f40: 00000006 00000006 c059b064 00000006 00000006 c0585094 c058db68 c0564480 5f60: c05850a0 c05c5800 000000a7 c0564c18 00000006 00000006 c0564480 c7833bc0 5f80: c7835f9c c0036da4 00000000 c043013c 00000000 00000000 00000000 00000000 5fa0: 00000000 c0430144 00000000 c0009490 00000000 00000000 00000000 00000000 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 df7f9b78 3b477df6 [] (mc13xxx_common_init+0x1fc/0x280) from [] (spi_drv_probe+0x18/0x1c) [] (spi_drv_probe+0x18/0x1c) from [] (driver_probe_device+0x78/0x20c) [] (driver_probe_device+0x78/0x20c) from [] (bus_for_each_drv+0x48/0x90) [] (bus_for_each_drv+0x48/0x90) from [] (device_attach+0x74/0x80) [] (device_attach+0x74/0x80) from [] (bus_probe_device+0x88/0xb0) [] (bus_probe_device+0x88/0xb0) from [] (device_add+0x31c/0x4c4) [] (device_add+0x31c/0x4c4) from [] (spi_add_device+0xa4/0x118) [] (spi_add_device+0xa4/0x118) from [] (spi_register_master+0x53c/0x6a0) [] (spi_register_master+0x53c/0x6a0) from [] (spi_bitbang_start+0x88/0x100) [] (spi_bitbang_start+0x88/0x100) from [] (spi_imx_probe+0x3a8/0x478) [] (spi_imx_probe+0x3a8/0x478) from [] (platform_drv_probe+0x18/0x48) [] (platform_drv_probe+0x18/0x48) from [] (driver_probe_device+0x78/0x20c) [] (driver_probe_device+0x78/0x20c) from [] (__driver_attach+0x8c/0x90) [] (__driver_attach+0x8c/0x90) from [] (bus_for_each_dev+0x5c/0x8c) [] (bus_for_each_dev+0x5c/0x8c) from [] (bus_add_driver+0xd4/0x1c8) [] (bus_add_driver+0xd4/0x1c8) from [] (driver_register+0x78/0xf4) [] (driver_register+0x78/0xf4) from [] (do_one_initcall+0x5c/0x168) [] (do_one_initcall+0x5c/0x168) from [] (kernel_init_freeable+0xe8/0x1a8) [] (kernel_init_freeable+0xe8/0x1a8) from [] (kernel_init+0x8/0x110) [] (kernel_init+0x8/0x110) from [] (ret_from_fork+0x14/0x24) Code: eaffffdb e3a03008 e1a00004 e59f107c (e5962018) ---[ end trace 71265dd116f3967e ]--- Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b Signed-off-by: Alexander Shiyan --- drivers/mfd/mc13xxx-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index dbbf8ee..625633a 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c @@ -682,14 +682,14 @@ err_revision: if (mc13xxx->flags & MC13XXX_USE_ADC) mc13xxx_add_subdevice(mc13xxx, "%s-adc"); - if (mc13xxx->flags & MC13XXX_USE_CODEC) + if ((mc13xxx->flags & MC13XXX_USE_CODEC) && pdata) mc13xxx_add_subdevice_pdata(mc13xxx, "%s-codec", pdata->codec, sizeof(*pdata->codec)); if (mc13xxx->flags & MC13XXX_USE_RTC) mc13xxx_add_subdevice(mc13xxx, "%s-rtc"); - if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) + if ((mc13xxx->flags & MC13XXX_USE_CODEC) && pdata) mc13xxx_add_subdevice_pdata(mc13xxx, "%s-ts", &pdata->touch, sizeof(pdata->touch)); @@ -701,6 +701,10 @@ err_revision: mc13xxx_add_subdevice_pdata(mc13xxx, "%s-pwrbutton", pdata->buttons, sizeof(*pdata->buttons)); } else { + if (mc13xxx->flags & MC13XXX_USE_CODEC) + mc13xxx_add_subdevice(mc13xxx, "%s-codec"); + if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) + mc13xxx_add_subdevice(mc13xxx, "%s-ts"); mc13xxx_add_subdevice(mc13xxx, "%s-regulator"); mc13xxx_add_subdevice(mc13xxx, "%s-led"); mc13xxx_add_subdevice(mc13xxx, "%s-pwrbutton");