Linux设备崩溃分析,ARM Linux崩溃分析(三) - 内核崩溃的实例分析

本文介绍了Linux设备驱动程序中因NULL指针解引用导致的内核崩溃问题。通过分析错误信息和栈回溯,确定错误发生在`test_init()`函数,错误源于尝试写入空指针。通过对内核崩溃时的栈信息和反汇编代码的解析,揭示了错误的来源和调用关系。
摘要由CSDN通过智能技术生成

测试代码如下:

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

static void test_crash(void)

{

char *pstr = NULL;

printk("drivr crash \n");

*pstr = 12;

printk("%s \n",pstr);

return;

}

static int __init test_init(void)

{

printk("drivr test \n");

test_crash();

return 0;

}

static void __exit test_exit(void)

{

printk("drivr exit \n");

return ;

}

module_init(test_init);

module_exit(test_exit);

MODULE_AUTHOR("Alex");

MODULE_LICENSE("GPL");

MODULE_DESCRIPTION("test driver");

MODULE_VERSION("v0.0.1");

修改成built-in模式,把驱动编译进内核

obj-y = driver_test.o

重新烧录内核,

启动报错如下:

……

drivr test

drivr crash

Unable to handle kernel NULL pointer dereference at virtual address 00000000

Mem abort info:

ESR = 0x96000045

Exception class = DABT (current EL), IL = 32 bits

SET = 0, FnV = 0

EA = 0, S1PTW = 0

Data abort info:

ISV = 0, ISS = 0x00000069

CM = 0, WnR = 1

pgd = ffffff8008979000

[00000000] *pgd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值