regmap_exit报segmentation fault

弋阳yoga 2020-08-10 03:30:31
出错的地方mutex_lock(),但是驱动中的使用方法并没有问题,不知道是哪出了问题,很奇怪

出错信息如下
Unable to handle kernel NULL pointer dereference at virtual address 00000070
pgd = a8bec000
[00000070] *pgd=38954831, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1] PREEMPT SMP ARM
Modules linked in: fxos8700cq(O-) 8192cu(O)
CPU: 0 PID: 643 Comm: rmmod Tainted: G O 4.1.15-g60bdf89-dirty #2
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
task: a87fbdc0 ti: a8e46000 task.ti: a8e46000
PC is at mutex_lock+0x10/0x50
LR is at debugfs_remove_recursive+0x48/0x1a0
pc : [<808351b0>] lr : [<8027e934>] psr: a00f0013
sp : a8e47eb8 ip : a81e3f64 fp : 016ead08
r10: 00000000 r9 : 8039f36c r8 : a6126cc0
r7 : a6126d10 r6 : a6126cc0 r5 : a6126d38 r4 : 00000070
r3 : a6003500 r2 : 00000000 r1 : a870e850 r0 : 00000070
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 10c53c7d Table: 38bec04a DAC: 00000015
Process rmmod (pid: 643, stack limit = 0xa8e46210)
Stack: (0xa8e47eb8 to 0xa8e48000)
7ea0: a8ab66a0 8027e934
7ec0: a8ab66a0 a8ab6600 00000003 a81e3e20 a8e47f08 803b439c a870e840 a8ab6600
7ee0: 00000003 a81e3e20 a8e47f08 803af908 a870e840 a870e8c0 00000003 a81e3e20
7f00: a8e47f08 8039eab4 a870e9c0 a870e840 a81e3e20 7f090a4c a81e3e54 00000081
7f20: 8000f544 a8e46000 00000000 8039bbb0 a81e3e20 7f090a4c a81e3e54 8039c344
7f40: 7f090a4c 016ead44 7eba1ab0 8039b908 7f090b0c 8008b6f8 a8903540 736f7866
7f60: 30303738 00007163 a87fc1b8 00000000 a87fc1b8 00000000 80c118a4 a87fbdc0
7f80: 016ead08 800449b8 a8e46000 8000f544 a8e47fb0 00000006 8000f544 7eba1c9c
7fa0: 00000002 8000f3c0 7eba1c9c 00000002 016ead44 00000800 76f00630 00002002
7fc0: 7eba1c9c 00000002 7eba1ab0 00000081 7eba1dc5 00000001 00000000 016ead08
7fe0: 76ec5ad0 7eba1a7c 0001f20c 76ec5adc 60070010 016ead44 4a292301 2100425b
[<808351b0>] (mutex_lock) from [<8027e934>] (debugfs_remove_recursive+0x48/0x1a0)
[<8027e934>] (debugfs_remove_recursive) from [<803b439c>] (regmap_debugfs_exit+0x1c/0xd0)
[<803b439c>] (regmap_debugfs_exit) from [<803af908>] (regmap_exit+0x14/0xa0)
[<803af908>] (regmap_exit) from [<8039eab4>] (release_nodes+0x168/0x1cc)
[<8039eab4>] (release_nodes) from [<8039bbb0>] (__device_release_driver+0x78/0xe4)
[<8039bbb0>] (__device_release_driver) from [<8039c344>] (driver_detach+0xac/0xb0)
[<8039c344>] (driver_detach) from [<8039b908>] (bus_remove_driver+0x4c/0xa0)
[<8039b908>] (bus_remove_driver) from [<8008b6f8>] (SyS_delete_module+0x174/0x1b8)
[<8008b6f8>] (SyS_delete_module) from [<8000f3c0>] (ret_fast_syscall+0x0/0x3c)
Code: e92d4010 e1a04000 f57ff05b f590f000 (e1903f9f)
---[ end trace d027e681bb2bb467 ]---
Segmentation fault


代码如下:

static int fxos8700cq_i2c_remove ( struct i2c_client* client )
{
struct fxos8700cq_data * pdata = i2c_get_clientdata(client);

fxos8700cq_device_stop(client);
misc_deregister(&fxos8700cq_acc_device);
regmap_exit ( pdata->regmap );
kfree(pdata);
return 0;
}
...全文
2643 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
glen30 2020-08-11
  • 打赏
  • 举报
回复
如果pdata为空的话,if(pdata->regmap)肯定有问题啊
应该是: if(pdata)
弋阳yoga 2020-08-11
  • 打赏
  • 举报
回复
这个没问题 在probe里面设置过了

	i2c_set_clientdata(client, pdata); 
弋阳yoga 2020-08-10
  • 打赏
  • 举报
回复
检查过了 之前这么写的时候也不对 if(pdata->regmap) regmap_exit ( pdata->regmap );
glen30 2020-08-10
  • 打赏
  • 举报
回复
这是空指针异常吧,检查下pdata是否为空呢

1,318

社区成员

发帖
与我相关
我的任务
社区描述
主要是开发驱动技术
社区管理员
  • 驱动程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧