Skip to contentSkip to conversation

WIFI: handle a neglected case in nl80211_new_interface()

PATCH In review Chao Bi 1 participant 3 messages Nov 27, 2013 – Nov 28, 2013 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Chao Bi

author
#0 lore raw

PATCH 1/1 WIFI: handle a neglected case in nl80211_new_interface()

In nl80211_new_interface(), it calls rdev_add_virtual_intf() to create a new interface, however, it only checks whether returned value is err code, but doesn't check if returned value is NULL. The returned value could be NULL, for example, memory allocation failed when creating a new interface.

when get a NULL returned value, nl80211_new_interface() is expected to return but it actually runs down to access the NULL pointer, this could lead to a panic.

---
 net/wireless/nl80211.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/nl80211.c +1 -1
index a1eb210..27feeaf 100644
@@ -2512,7 +2512,7 @@ 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 (!wdev || IS_ERR(wdev)) {
 		nlmsg_free(msg);
 		return PTR_ERR(wdev);
 	}
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): CAE2MWk=WEwxbnBDhBRHKVQ7JhAwKANv-HQXyK=qTb4qaH4GZRg@mail.gmail.com

author
#2 lore raw
Quoted 5 lines · Ujjal Roy

Hi,

We can use IS_ERR_OR_NULL(wdev) to check NULL as well as error value.

Quoted 7 lines

Thanks,
UjjaL

On Wed, Nov 27, 2013 at 8:30 AM, Chao Bi <[email protected]> wrote:
In nl80211_new_interface(), it calls rdev_add_virtual_intf() to create a new interface, however, it only checks whether returned value is err code, but doesn't check if returned value is NULL. The returned

Thanks Ujjal. I'll update it.

author
#3 lore raw
Quoted 9 lines · Chao Bi
Quoted 8 lines · Ujjal Roy

Hi,

We can use IS_ERR_OR_NULL(wdev) to check NULL as well as error value.

Thanks,
UjjaL

Quoted 7 lines
Quoted 4 lines · Chao Bi

In nl80211_new_interface(), it calls rdev_add_virtual_intf() to create a new interface, however, it only checks whether returned value is err code, but doesn't check if returned value is NULL. The returned

Thanks Ujjal. I'll update it.

Hi all,
This patch is not valid, I further check the nl80211 API introduce, don't need to handle this NULL return value because it bans NULL feedback of add_virtual_intf() API in cfg80211.h.