NFC: NCI: Cancel cmd_timer in nci_close_device()
authorAmitkumar Karwar <akarwar@marvell.com>
Mon, 23 Dec 2013 22:15:13 +0000 (14:15 -0800)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 5 Jan 2014 22:20:15 +0000 (23:20 +0100)
nci_close_device() sends nci reset command to the device.
If there is no response for this command, nci request timeout
occurs first and then cmd timeout happens. Because command
timer has started after sending the command.

We are immediately flushing command workqueue after nci
timeout. Later we will try to schedule cmd_work in command
timer which leads to a crash.

Cancel cmd_timer before flushing the workqueue to fix the
problem.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/nci/core.c

index f0e955e3a3853ee0dabc1daa6f35318dd68fab51..0a2ee83c3bd3363eacca540f0b95977d4329d341 100644 (file)
@@ -361,6 +361,8 @@ static int nci_close_device(struct nci_dev *ndev)
                      msecs_to_jiffies(NCI_RESET_TIMEOUT));
        clear_bit(NCI_INIT, &ndev->flags);
 
+       del_timer_sync(&ndev->cmd_timer);
+
        /* Flush cmd wq */
        flush_workqueue(ndev->cmd_wq);