Kernel起不来出现panic

转载自展讯FAQ

[QUESTION]
机器起来的时候,死在kernel中,系统起不来。出现panic,有出现如下红色log,其PC指针和LR指针指到了函数:

register_early_suspend,

[    4.641530] c2 PC is at register_early_suspend+0x20/0x88
[    4.646827] c2 LR is at register_early_suspend+0x14/0x88
[    4.652130] c2 pc : [<c00710f4>]    lr : [<c00710e8>]    psr: 00000113
[    4.652130] c2 sp : deca5f18  ip : c0252da4  fp : 00000000
[    4.664122] c2 r10: c0896a54  r9 : 00000000  r8 : c0879d24
[    4.669600] c2 r7 : c0980800  r6 : c089d9a8  r5 : c092094c  r4 : c0a573d0
[    4.676380] c2 r3 : 00000000  r2 : 00000033  r1 : 00000000  r0 : c0920964
[    4.683161] c2 Flags: nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[    4.690722] c2 Control: 10c53c7d  Table: 8000406a  DAC: 00000015

[ANSWER]

从堆栈里面看

[    5.555274] c2 [<c00710f4>] (register_early_suspend+0x20/0x88) from [<c0879d84>] (goodix_ts_init+0x60/0xb0)
[    5.565002] c2 [<c0879d84>] (goodix_ts_init+0x60/0xb0) from [<c00094fc>] (do_one_initcall+0xcc/0x180)
[    5.574218] c2 [<c00094fc>] (do_one_initcall+0xcc/0x180) from [<c0851b70>] (kernel_init_freeable+0xf4/0x1c0)
[    5.584039] c2 [<c0851b70>] (kernel_init_freeable+0xf4/0x1c0) from [<c05c1c1c>] (kernel_init+0x8/0xe4)
[    5.593338] c2 [<c05c1c1c>] (kernel_init+0x8/0xe4) from [<c000f518>] (ret_from_fork+0x14/0x3c)

从log看问题是register_early_suspend注册所导致,而代码中有goodix_ts_init函数,但去掉这个模块问题还是存在,其实这个问题的本质是register_early_suspend注册的时候出现了空指针所导致,可以在kernel中查找有调用了register_early_suspend的驱动,最终原因是:如下代码红色的部分被注释掉了,就是说register_early_suspend注册完成后就立即kfree释放了,从而导致出现了空指针被使用,导致panic

register_early_suspend(&led->early_suspend);
#endif

 led->sprd_torch_close(led);//disabled by default
 
 //return 0;
 
get_clk_fail:
config_of_fail:
 kfree(led);
 return ret;

你可能感兴趣的:(Kernel起不来出现panic)