315-brcmfmac-make-use-of-cfg80211_check_combinations.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From: Arend van Spriel <[email protected]>
  2. Date: Thu, 20 Aug 2015 22:06:05 +0200
  3. Subject: [PATCH] brcmfmac: make use of cfg80211_check_combinations()
  4. Use cfg80211_check_combinations() so we can bail out early when an
  5. interface add or change results in an invalid combination.
  6. Reviewed-by: Hante Meuleman <[email protected]>
  7. Reviewed-by: Franky (Zhenhui) Lin <[email protected]>
  8. Reviewed-by: Pieter-Paul Giesberts <[email protected]>
  9. Signed-off-by: Arend van Spriel <[email protected]>
  10. Signed-off-by: Kalle Valo <[email protected]>
  11. ---
  12. --- a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
  13. +++ b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
  14. @@ -469,6 +469,36 @@ brcmf_find_wpsie(const u8 *parse, u32 le
  15. return NULL;
  16. }
  17. +static int brcmf_vif_change_validate(struct brcmf_cfg80211_info *cfg,
  18. + struct brcmf_cfg80211_vif *vif,
  19. + enum nl80211_iftype new_type)
  20. +{
  21. + int iftype_num[NUM_NL80211_IFTYPES];
  22. + struct brcmf_cfg80211_vif *pos;
  23. +
  24. + memset(&iftype_num[0], 0, sizeof(iftype_num));
  25. + list_for_each_entry(pos, &cfg->vif_list, list)
  26. + if (pos == vif)
  27. + iftype_num[new_type]++;
  28. + else
  29. + iftype_num[pos->wdev.iftype]++;
  30. +
  31. + return cfg80211_check_combinations(cfg->wiphy, 1, 0, iftype_num);
  32. +}
  33. +
  34. +static int brcmf_vif_add_validate(struct brcmf_cfg80211_info *cfg,
  35. + enum nl80211_iftype new_type)
  36. +{
  37. + int iftype_num[NUM_NL80211_IFTYPES];
  38. + struct brcmf_cfg80211_vif *pos;
  39. +
  40. + memset(&iftype_num[0], 0, sizeof(iftype_num));
  41. + list_for_each_entry(pos, &cfg->vif_list, list)
  42. + iftype_num[pos->wdev.iftype]++;
  43. +
  44. + iftype_num[new_type]++;
  45. + return cfg80211_check_combinations(cfg->wiphy, 1, 0, iftype_num);
  46. +}
  47. static void convert_key_from_CPU(struct brcmf_wsec_key *key,
  48. struct brcmf_wsec_key_le *key_le)
  49. @@ -663,8 +693,14 @@ static struct wireless_dev *brcmf_cfg802
  50. struct vif_params *params)
  51. {
  52. struct wireless_dev *wdev;
  53. + int err;
  54. brcmf_dbg(TRACE, "enter: %s type %d\n", name, type);
  55. + err = brcmf_vif_add_validate(wiphy_to_cfg(wiphy), type);
  56. + if (err) {
  57. + brcmf_err("iface validation failed: err=%d\n", err);
  58. + return ERR_PTR(err);
  59. + }
  60. switch (type) {
  61. case NL80211_IFTYPE_ADHOC:
  62. case NL80211_IFTYPE_STATION:
  63. @@ -823,8 +859,12 @@ brcmf_cfg80211_change_iface(struct wiphy
  64. s32 ap = 0;
  65. s32 err = 0;
  66. - brcmf_dbg(TRACE, "Enter, ndev=%p, type=%d\n", ndev, type);
  67. -
  68. + brcmf_dbg(TRACE, "Enter, idx=%d, type=%d\n", ifp->bssidx, type);
  69. + err = brcmf_vif_change_validate(wiphy_to_cfg(wiphy), vif, type);
  70. + if (err) {
  71. + brcmf_err("iface validation failed: err=%d\n", err);
  72. + return err;
  73. + }
  74. switch (type) {
  75. case NL80211_IFTYPE_MONITOR:
  76. case NL80211_IFTYPE_WDS: