mac80211: allow passing NULL to ieee80211_vif_to_wdev()
authorJohannes Berg <johannes.berg@intel.com>
Wed, 10 Jun 2015 17:18:55 +0000 (20:18 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 17 Jul 2015 13:38:09 +0000 (15:38 +0200)
Simply return NULL in this case, instead of crashing. This can
simplify callers that would otherwise have to check for this
explicitly.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/util.c

index 7fb2c7bacc8cffb0e4f0fe5036fd34d75232697c..89e089c452c17930a5838474b114f4cdff569caf 100644 (file)
@@ -703,7 +703,12 @@ EXPORT_SYMBOL_GPL(wdev_to_ieee80211_vif);
 
 struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
 {
-       struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+       struct ieee80211_sub_if_data *sdata;
+
+       if (!vif)
+               return NULL;
+
+       sdata = vif_to_sdata(vif);
 
        if (!ieee80211_sdata_running(sdata) ||
            !(sdata->flags & IEEE80211_SDATA_IN_DRIVER))