libertas: don't use dynamic-sized array
authorAndrey Yurovsky <andrey@cozybit.com>
Fri, 14 Aug 2009 00:34:40 +0000 (17:34 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 20 Aug 2009 15:35:50 +0000 (11:35 -0400)
sparse complains about a bad constant expression due to the use of a
dynamic-sized array in get_common_rates().  Allocate and free the array
instead.

Signed-off-by: Andrey Yurovsky <andrey@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/assoc.c

index 385b50f4b1057d35812fdc4d544fabd765c4e7d6..81f86ef26990be2f703555916dee55bd0c7ffaad 100644 (file)
@@ -45,9 +45,14 @@ static int get_common_rates(struct lbs_private *priv,
        u8 *card_rates = lbs_bg_rates;
        size_t num_card_rates = sizeof(lbs_bg_rates);
        int ret = 0, i, j;
-       u8 tmp[30];
+       u8 *tmp;
        size_t tmp_size = 0;
 
+       tmp = kzalloc((ARRAY_SIZE(lbs_bg_rates) - 1) * (*rates_size - 1),
+                       GFP_KERNEL);
+       if (!tmp)
+               return -1;
+
        /* For each rate in card_rates that exists in rate1, copy to tmp */
        for (i = 0; card_rates[i] && (i < num_card_rates); i++) {
                for (j = 0; rates[j] && (j < *rates_size); j++) {
@@ -77,6 +82,7 @@ done:
        memset(rates, 0, *rates_size);
        *rates_size = min_t(int, tmp_size, *rates_size);
        memcpy(rates, tmp, *rates_size);
+       kfree(tmp);
        return ret;
 }