Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
omap: Avoid crashes in the case of hwmod misconfiguration
Browse files Browse the repository at this point in the history
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 torvalds#291)!
PC is at __clk_prepare+0x10/0x70!
LR is at clk_prepare+0x1c/0x34!
pc : [<c03e37f0>]    lr : [<c03e386c>]    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!
[<c03e37f0>] (__clk_prepare+0x10/0x70) from [<c03e386c>] (clk_prepare+0x1c/0x34)!
[<c03e386c>] (clk_prepare+0x1c/0x34) from [<c06d4e4c>] (_init+0x200/0x288)!
[<c06d4e4c>] (_init+0x200/0x288) from [<c0025e28>] (omap_hwmod_for_each+0x28/0x58)!
[<c0025e28>] (omap_hwmod_for_each+0x28/0x58) from [<c06d533c>] (omap_hwmod_setup_all+0x18/0x34)!
[<c06d533c>] (omap_hwmod_setup_all+0x18/0x34) from [<c0008870>] (do_one_initcall+0x90/0x160)!
[<c0008870>] (do_one_initcall+0x90/0x160) from [<c04a43d4>] (kernel_init+0xf8/0x290)!
[<c04a43d4>] (kernel_init+0xf8/0x290) from [<c000d678>] (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 <panto@antoniou-consulting.com>
  • Loading branch information
pantoniou authored and Robert Pohlink committed Sep 27, 2016
1 parent bd63ee0 commit d2118d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/arm/mach-omap2/omap_hwmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/*
Expand Down Expand Up @@ -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;
/*
Expand Down

0 comments on commit d2118d4

Please sign in to comment.