cfg80211: protect fools returning NULL in add_virtual_intf
authorRafał Miłecki <zajec5@gmail.com>
Fri, 14 Nov 2014 17:43:28 +0000 (18:43 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 19 Nov 2014 17:50:34 +0000 (18:50 +0100)
Callback add_virtual_intf is supposed to return ERR_PTR and trying to
return NULL results in some "Unable to handle kernel paging request",
etc. As it may be complicated to debug & trace, let's catch it (WARN).

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/nl80211.c

index dd5a827f9cb0eab7be01a1449d1bf007e766ba5f..5cfd75dfff673f15f0580c1693553a0d4652458f 100644 (file)
@@ -2645,7 +2645,10 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
        wdev = rdev_add_virtual_intf(rdev,
                                nla_data(info->attrs[NL80211_ATTR_IFNAME]),
                                type, err ? NULL : &flags, &params);
-       if (IS_ERR(wdev)) {
+       if (WARN_ON(!wdev)) {
+               nlmsg_free(msg);
+               return -EPROTO;
+       } else if (IS_ERR(wdev)) {
                nlmsg_free(msg);
                return PTR_ERR(wdev);
        }