diff options
Diffstat (limited to 'drivers/net/wireless/libertas/assoc.c')
-rw-r--r-- | drivers/net/wireless/libertas/assoc.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c index 1902b6f0b78c..385b50f4b105 100644 --- a/drivers/net/wireless/libertas/assoc.c +++ b/drivers/net/wireless/libertas/assoc.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* Copyright (C) 2006, Red Hat, Inc. */ | 1 | /* Copyright (C) 2006, Red Hat, Inc. */ |
2 | 2 | ||
3 | #include <linux/types.h> | 3 | #include <linux/types.h> |
4 | #include <linux/kernel.h> | ||
5 | #include <linux/etherdevice.h> | 4 | #include <linux/etherdevice.h> |
6 | #include <linux/ieee80211.h> | 5 | #include <linux/ieee80211.h> |
7 | #include <linux/if_arp.h> | 6 | #include <linux/if_arp.h> |
@@ -44,21 +43,21 @@ static int get_common_rates(struct lbs_private *priv, | |||
44 | u16 *rates_size) | 43 | u16 *rates_size) |
45 | { | 44 | { |
46 | u8 *card_rates = lbs_bg_rates; | 45 | u8 *card_rates = lbs_bg_rates; |
46 | size_t num_card_rates = sizeof(lbs_bg_rates); | ||
47 | int ret = 0, i, j; | 47 | int ret = 0, i, j; |
48 | u8 tmp[(ARRAY_SIZE(lbs_bg_rates) - 1) * (*rates_size - 1)]; | 48 | u8 tmp[30]; |
49 | size_t tmp_size = 0; | 49 | size_t tmp_size = 0; |
50 | 50 | ||
51 | /* For each rate in card_rates that exists in rate1, copy to tmp */ | 51 | /* For each rate in card_rates that exists in rate1, copy to tmp */ |
52 | for (i = 0; i < ARRAY_SIZE(lbs_bg_rates) && card_rates[i]; i++) { | 52 | for (i = 0; card_rates[i] && (i < num_card_rates); i++) { |
53 | for (j = 0; j < *rates_size && rates[j]; j++) { | 53 | for (j = 0; rates[j] && (j < *rates_size); j++) { |
54 | if (rates[j] == card_rates[i]) | 54 | if (rates[j] == card_rates[i]) |
55 | tmp[tmp_size++] = card_rates[i]; | 55 | tmp[tmp_size++] = card_rates[i]; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size); | 59 | lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size); |
60 | lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, | 60 | lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, num_card_rates); |
61 | ARRAY_SIZE(lbs_bg_rates)); | ||
62 | lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); | 61 | lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); |
63 | lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); | 62 | lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); |
64 | 63 | ||
@@ -70,7 +69,10 @@ static int get_common_rates(struct lbs_private *priv, | |||
70 | lbs_pr_alert("Previously set fixed data rate %#x isn't " | 69 | lbs_pr_alert("Previously set fixed data rate %#x isn't " |
71 | "compatible with the network.\n", priv->cur_rate); | 70 | "compatible with the network.\n", priv->cur_rate); |
72 | ret = -1; | 71 | ret = -1; |
72 | goto done; | ||
73 | } | 73 | } |
74 | ret = 0; | ||
75 | |||
74 | done: | 76 | done: |
75 | memset(rates, 0, *rates_size); | 77 | memset(rates, 0, *rates_size); |
76 | *rates_size = min_t(int, tmp_size, *rates_size); | 78 | *rates_size = min_t(int, tmp_size, *rates_size); |
@@ -318,7 +320,7 @@ static int lbs_associate(struct lbs_private *priv, | |||
318 | rates = (struct mrvl_ie_rates_param_set *) pos; | 320 | rates = (struct mrvl_ie_rates_param_set *) pos; |
319 | rates->header.type = cpu_to_le16(TLV_TYPE_RATES); | 321 | rates->header.type = cpu_to_le16(TLV_TYPE_RATES); |
320 | memcpy(&rates->rates, &bss->rates, MAX_RATES); | 322 | memcpy(&rates->rates, &bss->rates, MAX_RATES); |
321 | tmplen = min_t(u16, ARRAY_SIZE(rates->rates), MAX_RATES); | 323 | tmplen = MAX_RATES; |
322 | if (get_common_rates(priv, rates->rates, &tmplen)) { | 324 | if (get_common_rates(priv, rates->rates, &tmplen)) { |
323 | ret = -1; | 325 | ret = -1; |
324 | goto done; | 326 | goto done; |
@@ -592,7 +594,7 @@ static int lbs_adhoc_join(struct lbs_private *priv, | |||
592 | 594 | ||
593 | /* Copy Data rates from the rates recorded in scan response */ | 595 | /* Copy Data rates from the rates recorded in scan response */ |
594 | memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates)); | 596 | memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates)); |
595 | ratesize = min_t(u16, ARRAY_SIZE(cmd.bss.rates), MAX_RATES); | 597 | ratesize = min_t(u16, sizeof(cmd.bss.rates), MAX_RATES); |
596 | memcpy(cmd.bss.rates, bss->rates, ratesize); | 598 | memcpy(cmd.bss.rates, bss->rates, ratesize); |
597 | if (get_common_rates(priv, cmd.bss.rates, &ratesize)) { | 599 | if (get_common_rates(priv, cmd.bss.rates, &ratesize)) { |
598 | lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n"); | 600 | lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n"); |