diff options
| -rw-r--r-- | drivers/net/wireless/mwifiex/cfg80211.c | 25 |
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; |
| 1597 | error: | ||
| 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 | } |
| 1604 | EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf); | 1601 | EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf); |
| 1605 | 1602 | ||
