diff options
author | Johannes Berg <johannes.berg@intel.com> | 2011-11-18 10:23:01 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-21 16:20:49 -0500 |
commit | 80b998993d97d8a13589f8462e62a60298c72cf2 (patch) | |
tree | 0cbb131178d893c6a8e607c85a00d35693b81654 /net/wireless | |
parent | 7c4ef7122cef54dc49562eea35cbfaf0f44faa0b (diff) |
nl80211: make get_vlan logic more common
get_vlan() sets the output parameter even if it
returns an error, which is a bit odd. Instead,
convert it to use ERR_PTR.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/nl80211.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 9755b3f04dd7..889f06483862 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -2485,26 +2485,34 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) | |||
2485 | /* | 2485 | /* |
2486 | * Get vlan interface making sure it is running and on the right wiphy. | 2486 | * Get vlan interface making sure it is running and on the right wiphy. |
2487 | */ | 2487 | */ |
2488 | static int get_vlan(struct genl_info *info, | 2488 | static struct net_device *get_vlan(struct genl_info *info, |
2489 | struct cfg80211_registered_device *rdev, | 2489 | struct cfg80211_registered_device *rdev) |
2490 | struct net_device **vlan) | ||
2491 | { | 2490 | { |
2492 | struct nlattr *vlanattr = info->attrs[NL80211_ATTR_STA_VLAN]; | 2491 | struct nlattr *vlanattr = info->attrs[NL80211_ATTR_STA_VLAN]; |
2493 | *vlan = NULL; | 2492 | struct net_device *v; |
2494 | 2493 | int ret; | |
2495 | if (vlanattr) { | 2494 | |
2496 | *vlan = dev_get_by_index(genl_info_net(info), | 2495 | if (!vlanattr) |
2497 | nla_get_u32(vlanattr)); | 2496 | return NULL; |
2498 | if (!*vlan) | 2497 | |
2499 | return -ENODEV; | 2498 | v = dev_get_by_index(genl_info_net(info), nla_get_u32(vlanattr)); |
2500 | if (!(*vlan)->ieee80211_ptr) | 2499 | if (!v) |
2501 | return -EINVAL; | 2500 | return ERR_PTR(-ENODEV); |
2502 | if ((*vlan)->ieee80211_ptr->wiphy != &rdev->wiphy) | 2501 | |
2503 | return -EINVAL; | 2502 | if (!v->ieee80211_ptr || v->ieee80211_ptr->wiphy != &rdev->wiphy) { |
2504 | if (!netif_running(*vlan)) | 2503 | ret = -EINVAL; |
2505 | return -ENETDOWN; | 2504 | goto error; |
2506 | } | 2505 | } |
2507 | return 0; | 2506 | |
2507 | if (!netif_running(v)) { | ||
2508 | ret = -ENETDOWN; | ||
2509 | goto error; | ||
2510 | } | ||
2511 | |||
2512 | return v; | ||
2513 | error: | ||
2514 | dev_put(v); | ||
2515 | return ERR_PTR(ret); | ||
2508 | } | 2516 | } |
2509 | 2517 | ||
2510 | static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | 2518 | static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) |
@@ -2554,9 +2562,9 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | |||
2554 | params.plink_state = | 2562 | params.plink_state = |
2555 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); | 2563 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); |
2556 | 2564 | ||
2557 | err = get_vlan(info, rdev, ¶ms.vlan); | 2565 | params.vlan = get_vlan(info, rdev); |
2558 | if (err) | 2566 | if (IS_ERR(params.vlan)) |
2559 | goto out; | 2567 | return PTR_ERR(params.vlan); |
2560 | 2568 | ||
2561 | /* validate settings */ | 2569 | /* validate settings */ |
2562 | err = 0; | 2570 | err = 0; |
@@ -2724,9 +2732,9 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) | |||
2724 | (rdev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP))) | 2732 | (rdev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP))) |
2725 | return -EINVAL; | 2733 | return -EINVAL; |
2726 | 2734 | ||
2727 | err = get_vlan(info, rdev, ¶ms.vlan); | 2735 | params.vlan = get_vlan(info, rdev); |
2728 | if (err) | 2736 | if (IS_ERR(params.vlan)) |
2729 | goto out; | 2737 | return PTR_ERR(params.vlan); |
2730 | 2738 | ||
2731 | /* validate settings */ | 2739 | /* validate settings */ |
2732 | err = 0; | 2740 | err = 0; |