cdma: xilinx: Fix cdmatest driver crashing when unloading as a module
This patch fixes the issue cdmatest driver crashing when unloading as a module. get_task_struct and put_task_struct manage a thread's reference count. After we done get_task_struct, it will always be safe to access that memory, until we release it.If we call put_task_struct and We are the last one with a reference count, it does a bunch of cleanup. crash dump: zynq>rmmod cdmatest Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = 7e398000 [00000000] *pgd=3e286831, *pte=00000000, *ppte=00000000 Internal error: Oops - BUG: 17 [#1] PREEMPT SMP ARM Modules linked in: cdmatest(-) CPU: 1 PID: 630 Comm: rmmod Not tainted 4.0.0-xilinx-25051-gb6960df #34 Hardware name: Xilinx Zynq Platform task: 7e1f49c0 ti: 7e1ee000 task.ti: 7e1ee000 PC is at exit_creds+0x14/0x84 LR is at __put_task_struct+0x10/0x58 pc : [<400375d0>] lr : [<4001ead4>] psr: 60000013 sp : 7e1efec8 ip : 00000000 fp : 00200200 r10: 7e3705ac r9 : 00100100 r8 : 7d25dd0c r7 : 3f0016f0 r6 : 00000000 r5 : 7e13e648 r4 : 7e13e640 r3 : 00000000 r2 : 00000000 r1 : 60000013 r0 : 00000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 18c5387d Table: 3e39804a DAC: 00000015 Process rmmod (pid: 630, stack limit = 0x7e1ee210) Stack: (0x7e1efec8 to 0x7e1f0000) fec0: 7e13e640 4001ead4 7e13e640 40036448 7d25dd0c 7d25dd00 fee0: 7d25d580 3f0016f0 3f0016f0 3f0002f4 7e113000 7d25dd0c 00000000 7e113010 ff00: 3f001728 7e113044 00000081 4000df64 7e1ee000 00000000 00000000 40270458 ff20: 40270440 7e113010 3f001728 4026ece8 3f001728 7e113010 3f001728 4026f320 ff40: 3f001728 00000880 3ebf7f68 4026ea84 3f00176c 4006f2a4 7dc25880 616d6463 ff60: 74736574 45535500 00000020 00000000 7e1f49c0 7e1f4dc8 00000000 00000006 ff80: 7e1f49c0 7e1f4dc8 000f2040 40034da4 7e1ee000 001effb0 3ebf7f68 00000000 ffa0: 00000001 4000dde0 3ebf7f68 00000000 3ebf7f68 00000880 000fa0e0 00000000 ffc0: 3ebf7f68 00000000 00000001 00000081 00000001 00000000 3ebf7e8c 00000000 ffe0: 000fa0e0 3ebf7af0 0002cd74 36e5ba3c 60000010 3ebf7f68 00000000 00000000 [<400375d0>] (exit_creds) from [<4001ead4>] (__put_task_struct+0x10/0x58) [<4001ead4>] (__put_task_struct) from [<40036448>] (kthread_stop+0x90/0x98) [<40036448>] (kthread_stop) from [<3f0002f4>] (xilinx_cdmatest_remove+0x58/0xd0 [cdmatest]) [<3f0002f4>] (xilinx_cdmatest_remove [cdmatest]) from [<40270458>] (platform_drv_remove+0x18/0x30) [<40270458>] (platform_drv_remove) from [<4026ece8>] (__device_release_driver+0x7c/0xc0) [<4026ece8>] (__device_release_driver) from [<4026f320>] (driver_detach+0x84/0xac) [<4026f320>] (driver_detach) from [<4026ea84>] (bus_remove_driver+0x64/0x8c) [<4026ea84>] (bus_remove_driver) from [<4006f2a4>] (SyS_delete_module+0x154/0x1d0) [<4006f2a4>] (SyS_delete_module) from [<4000dde0>] (ret_fast_syscall+0x0/0x34) Code: e1a04000 e5903304 e3a02000 e5900300 (e5933000) ---[ end trace f700ab4d72219d3d ]--- Segmentation fault Signed-off-by:Kedareswara rao Appana <appanad@xilinx.com> Signed-off-by:
Michal Simek <michal.simek@xilinx.com>
Loading
Please sign in to comment