linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Yurovsky <andrey@cozybit.com>
To: linux-wireless@vger.kernel.org
Cc: dcbw@redhat.com, Andrey Yurovsky <andrey@cozybit.com>
Subject: [PATCH] libertas: don't use dynamic-sized array
Date: Thu, 13 Aug 2009 17:34:40 -0700	[thread overview]
Message-ID: <1250210080-21960-1-git-send-email-andrey@cozybit.com> (raw)
In-Reply-To: <43e72e890908131331q371320a3gf1ab53ea27574549@mail.gmail.com>

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>
---
 drivers/net/wireless/libertas/assoc.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 1902b6f..9834399 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -45,9 +45,14 @@ static int get_common_rates(struct lbs_private *priv,
 {
 	u8 *card_rates = lbs_bg_rates;
 	int ret = 0, i, j;
-	u8 tmp[(ARRAY_SIZE(lbs_bg_rates) - 1) * (*rates_size - 1)];
+	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; i < ARRAY_SIZE(lbs_bg_rates) && card_rates[i]; i++) {
 		for (j = 0; j < *rates_size && rates[j]; j++) {
@@ -75,6 +80,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;
 }
 
-- 
1.5.6.3


  parent reply	other threads:[~2009-08-14  0:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-13 20:31 Spare warnings - wireless drivers Luis R. Rodriguez
2009-08-13 20:51 ` Larry Finger
2009-08-14  0:34 ` Andrey Yurovsky [this message]
2009-08-19 17:09   ` [PATCH] libertas: don't use dynamic-sized array Dan Williams
2009-08-21 13:24     ` Dan Williams
2009-08-14 17:21 ` Spare warnings - wireless drivers Kalle Valo
2009-08-14 17:30 ` Dave
2009-08-14 18:10   ` Johannes Berg
2009-08-14 18:11     ` Gábor Stefanik
2009-08-14 19:33 ` reinette chatre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250210080-21960-1-git-send-email-andrey@cozybit.com \
    --to=andrey@cozybit.com \
    --cc=dcbw@redhat.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).