mwifiex: avoid double-disable_irq() race
authorBrian Norris <briannorris@chromium.org>
Fri, 18 Nov 2016 17:13:25 +0000 (22:43 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 25 Nov 2016 09:49:56 +0000 (11:49 +0200)
We have a race where the wakeup IRQ might be in flight while we're
calling mwifiex_disable_wake() from resume(). This can leave us
disabling the IRQ twice.

Let's disable the IRQ and enable it in case if we have double-disabled
it.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/main.h

index cf4c78080d94c115e95bfe365ec2e826f044537e..5c9bd944b6ea9a6c476aed143f306d4e17744c86 100644 (file)
@@ -1424,8 +1424,13 @@ static inline void mwifiex_disable_wake(struct mwifiex_adapter *adapter)
 {
        if (adapter->irq_wakeup >= 0) {
                disable_irq_wake(adapter->irq_wakeup);
-               if (!adapter->wake_by_wifi)
-                       disable_irq(adapter->irq_wakeup);
+               disable_irq(adapter->irq_wakeup);
+               if (adapter->wake_by_wifi)
+                       /* Undo our disable, since interrupt handler already
+                        * did this.
+                        */
+                       enable_irq(adapter->irq_wakeup);
+
        }
 }