iwlwifi: iwlagn_request_scan: Fix check for priv->scan_request
authorTim Gardner <tim.gardner@canonical.com>
Fri, 7 Dec 2012 13:28:34 +0000 (06:28 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 10 Dec 2012 21:38:58 +0000 (22:38 +0100)
The WARN_ON_ONCE() check for scan_request will not correctly detect
a NULL pointer for scan_type == IWL_SCAN_NORMAL. Make it explicit
that the check only applies to normal scans.

Convert WARN_ON_ONCE to WARN_ON since priv->scan_request really _can't_
be NULL for normal scans. If it is then we should emit frequent warnings.

This smatch warning led to scrutiny of iwlagn_request_scan():

drivers/net/wireless/iwlwifi/dvm/scan.c:894 iwlagn_request_scan() error: we previously assumed 'priv->scan_request' could be null (see line 792)

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/iwlwifi/dvm/scan.c

index aad5fa424a58c4d0b258d9d2d48879aa8e1117ef..610ed2204e1f197d7bbcb22e76de3ec0776fa05a 100644 (file)
@@ -673,8 +673,9 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        const u8 *ssid = NULL;
        u8 ssid_len = 0;
 
-       if (WARN_ON_ONCE(priv->scan_request &&
-                        priv->scan_request->n_channels > MAX_SCAN_CHANNEL))
+       if (WARN_ON(priv->scan_type == IWL_SCAN_NORMAL &&
+                   (!priv->scan_request ||
+                    priv->scan_request->n_channels > MAX_SCAN_CHANNEL)))
                return -EINVAL;
 
        lockdep_assert_held(&priv->mutex);