Skip to content
  • Aditya Shankar's avatar
    Staging: wilc1000: Fix kernel Oops on opening the device · 1d4f1d53
    Aditya Shankar authored
    Commit 2518ac59
    
     ("staging: wilc1000: Replace kthread with workqueue
    for host interface") adds an unconditional destroy_workqueue() on the
    wilc's "hif_workqueue" soon after its creation thereby rendering
    it unusable. It then further attempts to queue work onto this
    non-existing hif_worqueue and results in:
    
    Unable to handle kernel NULL pointer dereference at virtual address 00000010
    pgd = de478000
    [00000010] *pgd=3eec0831, *pte=00000000, *ppte=00000000
    Internal error: Oops: 17 [#1] ARM
    Modules linked in: wilc1000_sdio(C) wilc1000(C)
    CPU: 0 PID: 825 Comm: ifconfig Tainted: G         C      4.8.0-rc8+ #37
    Hardware name: Atmel SAMA5
    task: df56f800 task.stack: deeb0000
    PC is at __queue_work+0x90/0x284
    LR is at __queue_work+0x58/0x284
    pc : [<c0126bb0>]    lr : [<c0126b78>]    psr: 600f0093
    sp : deeb1aa0  ip : def22d78  fp : deea6000
    r10: 00000000  r9 : c0a08150  r8 : c0a2f058
    r7 : 00000001  r6 : dee9b600  r5 : def22d74  r4 : 00000000
    r3 : 00000000  r2 : def22d74  r1 : 07ffffff  r0 : 00000000
    Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
    ...
    [<c0127060>] (__queue_work) from [<c0127298>] (queue_work_on+0x34/0x40)
    [<c0127298>] (queue_work_on) from [<bf0076b4>] (wilc_enqueue_cmd+0x54/0x64 [wilc1000])
    [<bf0076b4>] (wilc_enqueue_cmd [wilc1000]) from [<bf0082b4>] (wilc_set_wfi_drv_handler+0x48/0x70 [wilc1000])
    [<bf0082b4>] (wilc_set_wfi_drv_handler [wilc1000]) from [<bf00509c>] (wilc_mac_open+0x214/0x250 [wilc1000])
    [<bf00509c>] (wilc_mac_open [wilc1000]) from [<c04fde98>] (__dev_open+0xb8/0x11c)
    [<c04fde98>] (__dev_open) from [<c04fe128>] (__dev_change_flags+0x94/0x158)
    [<c04fe128>] (__dev_change_flags) from [<c04fe204>] (dev_change_flags+0x18/0x48)
    [<c04fe204>] (dev_change_flags) from [<c0557d5c>] (devinet_ioctl+0x6b4/0x788)
    [<c0557d5c>] (devinet_ioctl) from [<c04e40a0>] (sock_ioctl+0x154/0x2cc)
    [<c04e40a0>] (sock_ioctl) from [<c01b16e0>] (do_vfs_ioctl+0x9c/0x878)
    [<c01b16e0>] (do_vfs_ioctl) from [<c01b1ef0>] (SyS_ioctl+0x34/0x5c)
    [<c01b1ef0>] (SyS_ioctl) from [<c0107520>] (ret_fast_syscall+0x0/0x3c)
    Code: e5932004 e1520006 01a04003 0affffff (e5943010)
    ---[ end trace b612328adaa6bf20 ]---
    
    This fix removes the unnecessary call to destroy_workqueue() while opening
    the device to avoid the above kernel panic. The deinit routine already
    does a good job of terminating the workqueue when no longer needed.
    
    Reported-by: default avatarNicolas Ferre <Nicolas.Ferre@microchip.com>
    Fixes: 2518ac59
    
     ("staging: wilc1000: Replace kthread with workqueue for host interface")
    Cc: stable@vger.kernel.org # 4.8+
    Signed-off-by: default avatarAditya Shankar <Aditya.Shankar@microchip.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    1d4f1d53