使用rmmod时出现分段错误

时间:2014-09-05 14:22:18

标签: linux linux-kernel linux-device-driver spi

我写了一个SPI设备驱动程序。出于某种原因,每次我使用rmmod我都会收到此错误。

root@am3517-evm:~# rmmod spi2.ko                                                
[  114.714660] kernel BUG at mm/slab.c:497!                                     
[  114.718811] BUG: sleeping function called from invalid context at arch/arm/mm
/fault.c:295                                                                    
[  114.727355] in_atomic(): 0, irqs_disabled(): 128, pid: 1491, name: rmmod     
[  114.734375] INFO: lockdep is turned off.                                     
[  114.738494] irq event stamp: 0                                               
[  114.741699] hardirqs last  enabled at (0): [<  (null)>]   (null)             
[  114.747985] hardirqs last disabled at (0): [<c00706e4>] copy_process+0x314/0x
e68                                                                             
[  114.755767] softirqs last  enabled at (0): [<c00706e4>] copy_process+0x314/0x
e68                                                                             
[  114.763519] softirqs last disabled at (0): [<  (null)>]   (null)             
[  114.769866] [<c004b690>] (unwind_backtrace+0x0/0xe0) from [<c0478928>] (do_pa
ge_fault+0xc0/0x2b0)                                                            
[  114.779174] [<c0478928>] (do_page_fault+0xc0/0x2b0) from [<c003c1f0>] (do_Dat
aAbort+0x30/0x98)                                                               
[  114.788208] [<c003c1f0>] (do_DataAbort+0x30/0x98) from [<c0476c6c>] (__dabt_s
vc+0x4c/0x60)                                                                   
[  114.796875] Exception stack(0xcecf7ed8 to 0xcecf7f20)                        
[  114.802185] 7ec0:                                                       00000
032 c05d7415                                                                    
[  114.810760] 7ee0: cecf7f14 00000000 bf04b4a0 00000000 a0000013 00000081 c0045
c48 cecf6000                                                                    
[  114.819366] 7f00: 00000000 00021008 c086a49c cecf7f20 c00495c0 c00495c4 20000
093 ffffffff                                                                    
[  114.827941] [<c0476c6c>] (__dabt_svc+0x4c/0x60) from [<c00495c4>] (__bug+0x1c
/0x28)                                                                          
[  114.835998] [<c00495c4>] (__bug+0x1c/0x28) from [<c00f70e0>] (kfree+0xac/0x11
c)                                                                              
[  114.843688] [<c00f70e0>] (kfree+0xac/0x11c) from [<bf04b3c4>] (spike_exit+0x5
8/0x8c [spi2])                                                                  
[  114.852478] [<bf04b3c4>] (spike_exit+0x58/0x8c [spi2]) from [<c00a87f8>] (sys
_delete_module+0x1b8/0x22c)                                                     
[  114.862457] [<c00a87f8>] (sys_delete_module+0x1b8/0x22c) from [<c0045a80>] (r
et_fast_syscall+0x0/0x3c)                                                       
[  114.872222] Unable to handle kernel NULL pointer dereference at virtual addre
ss 00000000                                                                     
[  114.880706] pgd = cd1e4000                                                   
[  114.883544] [00000000] *pgd=8d263031, *pte=00000000, *ppte=00000000          
[  114.890167] Internal error: Oops: 817 [#1]                                   
[  114.894470] last sysfs file: /sys/module/spi2/refcnt                         
[  114.899658] Modules linked in: spi2(-) bufferclass_ti omaplfb pvrsrvkm       
[  114.906555] CPU: 0    Tainted: G        W    (2.6.37 #1)                     
[  114.912109] PC is at __bug+0x1c/0x28                                         
[  114.915863] LR is at __bug+0x18/0x28                                         
[  114.919616] pc : [<c00495c4>]    lr : [<c00495c0>]    psr: 20000093          
[  114.919616] sp : cecf7f20  ip : c086a49c  fp : 00021008                      
[  114.931640] r10: 00000000  r9 : cecf6000  r8 : c0045c48                      
[  114.937133] r7 : 00000081  r6 : a0000013  r5 : 00000000  r4 : bf04b4a0       
[  114.943969] r3 : 00000000  r2 : cecf7f14  r1 : c05d7415  r0 : 00000032       
[  114.950805] Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment use
r                                                                               
[  114.958374] Control: 10c5387d  Table: 8d1e4019  DAC: 00000015                
[  114.964416] Process rmmod (pid: 1491, stack limit = 0xcecf62f0)              
[  114.970611] Stack: (0xcecf7f20 to 0xcecf8000)                                
[  114.975189] 7f20: c0de0960 c00f70e0 bf04b8c8 00000000 00021d50 00000081 c0045
c48 bf04b3c4                                                                    
[  114.983764] 7f40: bf04b750 c00a87f8 cd1beac0 32697073 00000000 00000000 cecb7
140 cd1beac0                                                                    
[  114.992370] 7f60: 00000000 cef860c0 00000003 c0045c48 cd1beac0 00000000 cef86
0c0 c00f8f3c                                                                    
[  115.000946] 7f80: cef860c0 00f860e4 bf04b750 00000800 cecf7f94 00000000 00000
001 00021d20                                                                    
[  115.009521] 7fa0: bed1edbc c0045a80 00000001 00021d20 00021d50 00000800 00000
000 00000000                                                                    
[  115.018096] 7fc0: 00000001 00021d20 bed1edbc 00000081 00021d20 00000000 00000
800 00021008                                                                    
[  115.026702] 7fe0: bed1eeaf bed1eb60 49e60968 49dee56c 20000010 00021d50 00000
000 00000000                                                                    
[  115.035278] [<c00495c4>] (__bug+0x1c/0x28) from [<c00f70e0>] (kfree+0xac/0x11
c)                                                                              
[  115.042968] [<c00f70e0>] (kfree+0xac/0x11c) from [<bf04b3c4>] (spike_exit+0x5
8/0x8c [spi2])                                                                  
[  115.051757] [<bf04b3c4>] (spike_exit+0x58/0x8c [spi2]) from [<c00a87f8>] (sys
_delete_module+0x1b8/0x22c)                                                     
[  115.061706] [<c00a87f8>] (sys_delete_module+0x1b8/0x22c) from [<c0045a80>] (r
et_fast_syscall+0x0/0x3c)                                                       
[  115.071472] Code: e59f0010 e1a01003 eb10a85c e3a03000 (e5833000)             
[  115.083648] ---[ end trace 1b75b31a2719ed1f ]---                             
Segmentation fault 

我不确定为什么我会收到此错误。我检查过,似乎没有我正在访问的NULL指针。关于为什么会发生这种情况的任何想法?

1 个答案:

答案 0 :(得分:0)

设法解决了这个错误。事实证明我没有正确地将数据从一个字符串复制到另一个字符串,这导致将空指针传递给我用于某些计算的字符串