wil6210: fix potential null dereference of ndev before null check
authorColin Ian King <colin.king@canonical.com>
Wed, 28 Mar 2018 17:40:27 +0000 (18:40 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 10 Apr 2018 14:29:10 +0000 (17:29 +0300)
The pointer ndev is being dereferenced before it is being null checked,
hence there is a potential null pointer deference. Fix this by only
dereferencing ndev after it has been null checked

Detected by CoverityScan, CID#1467010 ("Dereference before null check")

Fixes: e00243fab84b ("wil6210: infrastructure for multiple virtual interfaces")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/wil6210/main.c

index a4b413e8d55a3facf9f88604dba90744155278c0..82aec6b06d09b9169403fc16948c1c6f8d48d11c 100644 (file)
@@ -391,7 +391,7 @@ static void wil_fw_error_worker(struct work_struct *work)
        struct wil6210_priv *wil = container_of(work, struct wil6210_priv,
                                                fw_error_worker);
        struct net_device *ndev = wil->main_ndev;
-       struct wireless_dev *wdev = ndev->ieee80211_ptr;
+       struct wireless_dev *wdev;
 
        wil_dbg_misc(wil, "fw error worker\n");
 
@@ -399,6 +399,7 @@ static void wil_fw_error_worker(struct work_struct *work)
                wil_info(wil, "No recovery - interface is down\n");
                return;
        }
+       wdev = ndev->ieee80211_ptr;
 
        /* increment @recovery_count if less then WIL6210_FW_RECOVERY_TO
         * passed since last recovery attempt