]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ath9k_htc: Fix WMI command race
authorSujith <Sujith.Manoharan@atheros.com>
Fri, 23 Apr 2010 04:58:19 +0000 (10:28 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 26 Apr 2010 18:21:21 +0000 (14:21 -0400)
My patch "ath9k_htc: Handle WMI timeouts properly" introduced
a race condition in WMI command processing. The last issued command
should be stored _before_ issuing a WMI command. Not doing this
would result in the WMI event IRQ dropping correct command responses
as invalid.

Fix this race by storing the command id correctly.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/wmi.c

index c688545326592af48b85274007cfa82814ae9503..e23172c9caaf1e038a2ee0b91556c008062030cc 100644 (file)
@@ -305,14 +305,14 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
        wmi->cmd_rsp_buf = rsp_buf;
        wmi->cmd_rsp_len = rsp_len;
 
-       ret = ath9k_wmi_cmd_issue(wmi, skb, cmd_id, cmd_len);
-       if (ret)
-               goto out;
-
        spin_lock_irqsave(&wmi->wmi_lock, flags);
        wmi->last_cmd_id = cmd_id;
        spin_unlock_irqrestore(&wmi->wmi_lock, flags);
 
+       ret = ath9k_wmi_cmd_issue(wmi, skb, cmd_id, cmd_len);
+       if (ret)
+               goto out;
+
        time_left = wait_for_completion_timeout(&wmi->cmd_wait, timeout);
        if (!time_left) {
                ath_print(common, ATH_DBG_WMI,