aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorBing Zhao <bzhao@marvell.com>2012-06-15 18:49:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-06-19 14:59:19 -0400
commit858faa57dd9e2b91f3f870fbb1185982e42f5a2b (patch)
tree145bd3842a6d1af9b2e7ac2b6c90185443811778 /drivers/net
parent7f59ebb5f34380696d16094fa1090485ec077fb1 (diff)
mwifiex: fix wrong return values in add_virtual_intf() error cases
add_virtual_intf() needs to return an ERR_PTR(), instead of NULL, on errors, otherwise cfg80211 will crash. Reported-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 015fec3371a0..ce61b6fae1c9 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1484,7 +1484,7 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1484 struct wireless_dev *wdev; 1484 struct wireless_dev *wdev;
1485 1485
1486 if (!adapter) 1486 if (!adapter)
1487 return NULL; 1487 return ERR_PTR(-EFAULT);
1488 1488
1489 switch (type) { 1489 switch (type) {
1490 case NL80211_IFTYPE_UNSPECIFIED: 1490 case NL80211_IFTYPE_UNSPECIFIED:
@@ -1494,12 +1494,12 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1494 if (priv->bss_mode) { 1494 if (priv->bss_mode) {
1495 wiphy_err(wiphy, 1495 wiphy_err(wiphy,
1496 "cannot create multiple sta/adhoc ifaces\n"); 1496 "cannot create multiple sta/adhoc ifaces\n");
1497 return NULL; 1497 return ERR_PTR(-EINVAL);
1498 } 1498 }
1499 1499
1500 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); 1500 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
1501 if (!wdev) 1501 if (!wdev)
1502 return NULL; 1502 return ERR_PTR(-ENOMEM);
1503 1503
1504 wdev->wiphy = wiphy; 1504 wdev->wiphy = wiphy;
1505 priv->wdev = wdev; 1505 priv->wdev = wdev;
@@ -1522,12 +1522,12 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1522 1522
1523 if (priv->bss_mode) { 1523 if (priv->bss_mode) {
1524 wiphy_err(wiphy, "Can't create multiple AP interfaces"); 1524 wiphy_err(wiphy, "Can't create multiple AP interfaces");
1525 return NULL; 1525 return ERR_PTR(-EINVAL);
1526 } 1526 }
1527 1527
1528 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); 1528 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
1529 if (!wdev) 1529 if (!wdev)
1530 return NULL; 1530 return ERR_PTR(-ENOMEM);
1531 1531
1532 priv->wdev = wdev; 1532 priv->wdev = wdev;
1533 wdev->wiphy = wiphy; 1533 wdev->wiphy = wiphy;
@@ -1544,14 +1544,15 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1544 break; 1544 break;
1545 default: 1545 default:
1546 wiphy_err(wiphy, "type not supported\n"); 1546 wiphy_err(wiphy, "type not supported\n");
1547 return NULL; 1547 return ERR_PTR(-EINVAL);
1548 } 1548 }
1549 1549
1550 dev = alloc_netdev_mq(sizeof(struct mwifiex_private *), name, 1550 dev = alloc_netdev_mq(sizeof(struct mwifiex_private *), name,
1551 ether_setup, 1); 1551 ether_setup, 1);
1552 if (!dev) { 1552 if (!dev) {
1553 wiphy_err(wiphy, "no memory available for netdevice\n"); 1553 wiphy_err(wiphy, "no memory available for netdevice\n");
1554 goto error; 1554 priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
1555 return ERR_PTR(-ENOMEM);
1555 } 1556 }
1556 1557
1557 mwifiex_init_priv_params(priv, dev); 1558 mwifiex_init_priv_params(priv, dev);
@@ -1582,7 +1583,9 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1582 /* Register network device */ 1583 /* Register network device */
1583 if (register_netdevice(dev)) { 1584 if (register_netdevice(dev)) {
1584 wiphy_err(wiphy, "cannot register virtual network device\n"); 1585 wiphy_err(wiphy, "cannot register virtual network device\n");
1585 goto error; 1586 free_netdev(dev);
1587 priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
1588 return ERR_PTR(-EFAULT);
1586 } 1589 }
1587 1590
1588 sema_init(&priv->async_sem, 1); 1591 sema_init(&priv->async_sem, 1);
@@ -1594,12 +1597,6 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1594 mwifiex_dev_debugfs_init(priv); 1597 mwifiex_dev_debugfs_init(priv);
1595#endif 1598#endif
1596 return dev; 1599 return dev;
1597error:
1598 if (dev && (dev->reg_state == NETREG_UNREGISTERED))
1599 free_netdev(dev);
1600 priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
1601
1602 return NULL;
1603} 1600}
1604EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf); 1601EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf);
1605 1602