Unable to handle kernel NULL pointer dereference at virtual address 00000058的错误解决

完整的错误信息是这样的:

[  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


在网上查了一下,说要用gdb来debug定位,我没有用过,想想先看看代码吧。

然后查代码,看看有没有数组越界或者内存分配的问题。

最后终于发现是一个地方没有释放内存。

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);

}


这里给_buf指针分配了内存空间,可是运行完之后没有及时释放,导致这个函数多次调用之后内存耗尽,系统死机。

在后面加上:

	kfree(_buf);

可以解决。






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值