转载自展讯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
从堆栈里面看
[ 5.555274] c2 [<c00710f4>] (register_early_suspend+0x20/0x88) from [<c0879d84>] (goodix_ts_init+0x60/0xb0)从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;