Linux Device Driver

解決"module_put"問題


參考資訊:
1. linux-kernel-modules-when-to-use-try-module-get-module-put

問題如下:

[   24.586438] ------------[ cut here ]------------
[   24.591363] WARNING: CPU: 0 PID: 84 at kernel/module.c:967 module_put+0xa0/0xb4()
[   24.599345] Modules linked in: main(PO)
[   24.603421] CPU: 0 PID: 84 Comm: app Tainted: P        W  O    4.1.18 #1
[   24.610508] Hardware name: Generic AM33XX (Flattened Device Tree)
[   24.616932] Backtrace: 
[   24.619557] [<c0012b18>] (dump_backtrace) from [<c0012d38>] (show_stack+0x18/0x1c)
[   24.627557]  r7:c0854fd8 r6:000003c7 r5:00000009 r4:00000000
[   24.633585] [<c0012d20>] (show_stack) from [<c06b9e28>] (dump_stack+0x20/0x28)
[   24.641237] [<c06b9e08>] (dump_stack) from [<c0035d40>] (warn_slowpath_common+0x7c/0xb4)
[   24.649785] [<c0035cc4>] (warn_slowpath_common) from [<c0035e1c>] (warn_slowpath_null+0x24/0x2c)
[   24.659039]  r8:ddc42d40 r7:00000000 r6:ddc33790 r5:dd082440 r4:ddc36900
[   24.666196] [<c0035df8>] (warn_slowpath_null) from [<c008add0>] (module_put+0xa0/0xb4)
[   24.674540] [<c008ad30>] (module_put) from [<c01050b0>] (__fput+0xb4/0x20c)
[   24.681900] [<c0104ffc>] (__fput) from [<c0105260>] (____fput+0x10/0x14)
[   24.688996]  r10:00000000 r9:ddc64000 r8:c000fa24 r7:ddc74828 r6:c099f30c r5:ddc74480
[   24.697338]  r4:00000000
[   24.700046] [<c0105250>] (____fput) from [<c004e004>] (task_work_run+0x94/0xc4)
[   24.707785] [<c004df70>] (task_work_run) from [<c00127bc>] (do_work_pending+0x8c/0xb4)
[   24.716125]  r7:00000006 r6:ddc65fb0 r5:c000fa24 r4:ddc64000
[   24.722148] [<c0012730>] (do_work_pending) from [<c000f8cc>] (work_pending+0xc/0x20)
[   24.730300]  r7:00000006 r6:00000000 r5:00000000 r4:bebd0d18
[   24.736341] ---[ end trace c4d06157b8bb6695 ]---

解法就是把.owner = THIS_MODULE拿掉

struct file_operations fops = {
    ...
    //.owner = THIS_MODULE,
    ...
};


返回上一頁