完整的错误信息是这样的:
[ 187.757290] Unable to handle kernel NULL pointer dereference at virtual address 00000058
[ 187.766406] pgd = c0004000
[ 187.769543] [00000058] *pgd=00000000
[ 187.773666] Internal error: [CPU_FREQ=24*N*K/(M*P) MHz], N=21, K=2, M=1, P=1
[ 187.781657] Internal error: enable JTAG PB/PF
[ 187.786584] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[ 187.792578] Modules linked in: udf loop hello spi_sun7i rtl8150 uvcvideo videobuf_dma_contig videobuf_core mali(O) ump(O) gpio_sunxi sun7i_ir nand(O) [last unloaded: 8188eu]
[ 187.811077] CPU: 0 Tainted: G W O (3.4.39+ #194)
[ 187.817470] PC is at __raw_spin_lock_irqsave+0x38/0xa4
[ 187.823332] LR is at __raw_spin_lock_irqsave+0x2c/0xa4
[ 187.829155] pc : [<c0594620>] lr : [<c0594614>] psr: 20000193
[ 187.829165] sp : c0857dc0 ip : c0857dc0 fp : c0857dd4
[ 187.842166] r10: 00000000 r9 : 410fc074 r8 : 0000003b
[ 187.848114] r7 : c08c8370 r6 : 00000000 r5 : c0856000 r4 : 00000058
[ 187.855457] r3 : c0857dc0 r2 : 00000001 r1 : 00000000 r0 : 20000193
[ 187.862859] Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel
[ 187.871178] Control: 10c5387d Table: 6970c06a DAC: 00000015
[ 187.877713]
[ 187.877717] PC: 0xc05945a0:
[ 187.882610] 45a0 e3530000 03a03001 05843004 eaffffff e5943000 e3530000 0affffe7 e5943004
[ 187.892486] 45c0 e3530000 1afffff9 eaffffe3 e1a0c00d e92dd800 e24cb004 e92d4000 e8bd4000
[ 187.902345] 45e0 ebffffd4 e89da800 e1a0c00d e92dd830 e24cb004 e92d4000 e8bd4000 e1a0300d
[ 187.912208] 4600 e1a04000 e3c35d7f e3c5503f e3a00001 ebebb756 e10f0000 f10c0080 e3a02001
[ 187.922020] 4620 e1943f9f e3330000 01843f92 e3530000 1a000002 f57ff05f e5843004 e89da830
[ 187.931826] 4640 e121f000 e3a00001 ebebb710 e5953000 e3130002 0a000000 ebfffb9d e5943004
[ 187.941692] 4660 e3530000 03a03001 05843004 eaffffff e5943000 e3530000 0affffe3 e5943004
[ 187.951505] 4680 e3530000 1afffff9 eaffffdf e1a0c00d e92dd800 e24cb004 e92d4000 e8bd4000
[ 187.961373]
[ 187.961376] LR: 0xc0594594:
[ 187.966331] 4594 0a000000 ebfffbcd e5943004 e3530000 03a03001 05843004 eaffffff e5943000
然后查代码,看看有没有数组越界或者内存分配的问题。
最后终于发现是一个地方没有释放内存。
void write_buffer_to_dvd(char * buf, __u32 count){
u16 cmd[6];
u8 *_buf;
_buf = kmalloc(count+SPI_CMD_LEN,GFP_KERNEL);
cmd[0] = FILE_READ_HEADER;
cmd[1] = FILE_WRITE_CMD;
cmd[2] = (count >> 16)&0x0000ffff;
cmd[3] = count & 0x0000ffff;
/*for(w_cnt=0;w_cnt < count;w_cnt++){
buf[w_cnt] = w_cnt;
}*/
memcpy(_buf,(u8*)cmd, SPI_CMD_LEN);
memcpy(_buf+SPI_CMD_LEN,buf,count);
spi_setup_dma_for_tx(_buf, count+SPI_CMD_LEN);
}
在后面加上:
kfree(_buf);
可以解决。