测试代码如下:
#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