staging: wlan-ng: Fix dereference before NULL check
authorEmil Goode <emilgoode@gmail.com>
Tue, 18 Sep 2012 16:04:07 +0000 (18:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2012 08:28:14 +0000 (09:28 +0100)
Smatch is warning about a dereference before we check for NULL.
This patch moves the dereference to after the NULL check.

Smatch warning:
drivers/staging/wlan-ng/cfg80211.c:345 prism2_scan() warn:
variable dereferenced before check 'request' (see line 332)

Signed-off-by: Emil Goode <emilgoode@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wlan-ng/cfg80211.c

index 0970127344e60828e569e1ca87ee6c82cb3f11eb..57a2b058e3dee3eac2d6e5467036d43ef57312b3 100644 (file)
@@ -329,9 +329,9 @@ int prism2_get_station(struct wiphy *wiphy, struct net_device *dev,
 
 int prism2_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 {
-       struct net_device *dev = request->wdev->netdev;
+       struct net_device *dev;
        struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
-       wlandevice_t *wlandev = dev->ml_priv;
+       wlandevice_t *wlandev;
        struct p80211msg_dot11req_scan msg1;
        struct p80211msg_dot11req_scan_results msg2;
        struct cfg80211_bss *bss;
@@ -345,6 +345,9 @@ int prism2_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
        if (!request)
                return -EINVAL;
 
+       dev = request->wdev->netdev;
+       wlandev = dev->ml_priv;
+
        if (priv->scan_request && priv->scan_request != request)
                return -EBUSY;