From patchwork Tue Jan 8 13:31:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pantelis Antoniou X-Patchwork-Id: 1945761 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C13213FED4 for ; Tue, 8 Jan 2013 13:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756380Ab3AHNcE (ORCPT ); Tue, 8 Jan 2013 08:32:04 -0500 Received: from li42-95.members.linode.com ([209.123.162.95]:51746 "EHLO li42-95.members.linode.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756362Ab3AHNcC (ORCPT ); Tue, 8 Jan 2013 08:32:02 -0500 Received: from sles11esa.localdomain (unknown [195.97.110.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: panto) by li42-95.members.linode.com (Postfix) with ESMTPSA id 0DB4C9C0C3; Tue, 8 Jan 2013 13:31:58 +0000 (UTC) From: Pantelis Antoniou Cc: Tony Lindgren , Stephen Warren , Benoit Cousson , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Matt Porter , Russ Dill , Koen Kooi , Joel A Fernandes , Rob Clark , Jason Kridner , Matt Ranostay , Pantelis Antoniou Subject: [PATCH] omap: Avoid crashes in the case of hwmod misconfiguration Date: Tue, 8 Jan 2013 15:31:57 +0200 Message-Id: <1357651917-22002-1-git-send-email-panto@antoniou-consulting.com> X-Mailer: git-send-email 1.7.12 To: unlisted-recipients:; (no To-header on input) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org omap hwmod is really sensitive to hwmod misconfiguration. Getting a minor clock wrong always ended up in a crash. Attempt to be more resilient by not assigning variables with error codes and then attempting to use them. Without this patch, missing a clock ends up with something like this: omap_hwmod: ehrpwm0: cannot clk_get opt_clk ehrpwm0_tbclk! Unable to handle kernel NULL pointer dereference at virtual address 0000002a! pgd = c0004000! [0000002a] *pgd=00000000! Internal error: Oops: 5 [#1] SMP ARM! Modules linked in:! CPU: 0 Not tainted (3.8.0-rc2-12157-g76c7825-dirty #291)! PC is at __clk_prepare+0x10/0x70! LR is at clk_prepare+0x1c/0x34! pc : [] lr : [] psr: a0000113! sp : cf04fef8 ip : 22222222 fp : 00000000! r10: ffffffea r9 : 00000000 r8 : 00000000! r7 : fffffffe r6 : 00000001 r5 : fffffffe r4 : fffffffe! r3 : cf041ac0 r2 : cf04ff00 r1 : 22222222 r0 : fffffffe! Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel! Control: 10c5387d Table: 80004019 DAC: 00000015! Process swapper/0 (pid: 1, stack limit = 0xcf04e240)! Stack: (0xcf04fef8 to 0xcf050000)! fee0: cf041ac0 c07749f4! ff00: fffffffe c03e386c c07499cc c073c070 c073d2fc c06d4e4c c073c070 c071cc18! ff20: c06d4c4c 00000000 00000000 c0708284 c06c91bc c0025e28 c073a030 00000001! ff40: c06f5f60 c06f5f40 c06d5324 c06d533c cf04e000 c0008870 c06d5324 c060abe8! ff60: c07082e8 00000002 00000001 c06f5f60 c06f5f40 c077d700 00000099 c04a43d4! ff80: 00000001 00000001 c06c91bc 00000000 00000000 c04a42dc 00000000 00000000! ffa0: 00000000 00000000 00000000 c000d678 00000000 00000000 00000000 00000000! ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000! ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 9e7befee f7bbaaab! [] (__clk_prepare+0x10/0x70) from [] (clk_prepare+0x1c/0x34)! [] (clk_prepare+0x1c/0x34) from [] (_init+0x200/0x288)! [] (_init+0x200/0x288) from [] (omap_hwmod_for_each+0x28/0x58)! [] (omap_hwmod_for_each+0x28/0x58) from [] (omap_hwmod_setup_all+0x18/0x34)! [] (omap_hwmod_setup_all+0x18/0x34) from [] (do_one_initcall+0x90/0x160)! [] (do_one_initcall+0x90/0x160) from [] (kernel_init+0xf8/0x290)! [] (kernel_init+0xf8/0x290) from [] (ret_from_fork+0x14/0x3c)! Code: e92d4038 e2504000 01a05004 0a000015 (e594302c) ! ---[ end trace 1b75b31a2719ed1c ]---! Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b! Signed-off-by: Pantelis Antoniou --- arch/arm/mach-omap2/omap_hwmod.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 4653efb..2b58e21 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -783,7 +783,9 @@ static int _init_interface_clks(struct omap_hwmod *oh) if (IS_ERR(c)) { pr_warning("omap_hwmod: %s: cannot clk_get interface_clk %s\n", oh->name, os->clk); - ret = -EINVAL; + if (ret == 0) + ret = -EINVAL; + continue; } os->_clk = c; /* @@ -819,7 +821,9 @@ static int _init_opt_clks(struct omap_hwmod *oh) if (IS_ERR(c)) { pr_warning("omap_hwmod: %s: cannot clk_get opt_clk %s\n", oh->name, oc->clk); - ret = -EINVAL; + if (ret == 0) + ret = -EINVAL; + continue; } oc->_clk = c; /*