From: Bing Zhao <bzhao@marvell.com>
To: linux-wireless@vger.kernel.org
Cc: "John W. Linville" <linville@tuxdriver.com>,
Johannes Berg <johannes@sipsolutions.net>,
Amitkumar Karwar <akarwar@marvell.com>,
Kiran Divekar <dkiran@marvell.com>,
Yogesh Powar <yogeshp@marvell.com>,
Marc Yang <yangyang@marvell.com>,
Frank Huang <frankh@marvell.com>, Bing Zhao <bzhao@marvell.com>
Subject: [PATCH 2/4] mwifiex: use dynamic allocation for large size structure
Date: Thu, 10 Mar 2011 16:25:47 -0800 [thread overview]
Message-ID: <1299803149-25996-2-git-send-email-bzhao@marvell.com> (raw)
In-Reply-To: <1299803149-25996-1-git-send-email-bzhao@marvell.com>
From: Amitkumar Karwar <akarwar@marvell.com>
'make checkstack' found:
0x0000f9ee mwifiex_cfg80211_results [mwifiex]: 760
struct mwifiex_user_scan_cfg has big array inside.
Change the code to use kzalloc so that mwifiex_cfg80211_results()
routine uses less than 512 bytes on the stack.
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
drivers/net/wireless/mwifiex/cfg80211.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 6aa5962..d34c622 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1453,32 +1453,38 @@ mwifiex_cfg80211_results(struct work_struct *work)
{
struct mwifiex_private *priv =
container_of(work, struct mwifiex_private, cfg_workqueue);
- struct mwifiex_user_scan_cfg scan_req;
+ struct mwifiex_user_scan_cfg *scan_req;
int ret = 0, i;
struct ieee80211_channel *chan;
if (priv->scan_request) {
- memset(&scan_req, 0x00, sizeof(scan_req));
+ scan_req = kzalloc(sizeof(struct mwifiex_user_scan_cfg),
+ GFP_KERNEL);
+ if (!scan_req) {
+ dev_err(priv->adapter->dev, "failed to alloc "
+ "scan_req\n");
+ return;
+ }
for (i = 0; i < priv->scan_request->n_ssids; i++) {
- memcpy(scan_req.ssid_list[i].ssid,
+ memcpy(scan_req->ssid_list[i].ssid,
priv->scan_request->ssids[i].ssid,
priv->scan_request->ssids[i].ssid_len);
- scan_req.ssid_list[i].max_len =
+ scan_req->ssid_list[i].max_len =
priv->scan_request->ssids[i].ssid_len;
}
for (i = 0; i < priv->scan_request->n_channels; i++) {
chan = priv->scan_request->channels[i];
- scan_req.chan_list[i].chan_number = chan->hw_value;
- scan_req.chan_list[i].radio_type = chan->band;
+ scan_req->chan_list[i].chan_number = chan->hw_value;
+ scan_req->chan_list[i].radio_type = chan->band;
if (chan->flags & IEEE80211_CHAN_DISABLED)
- scan_req.chan_list[i].scan_type =
+ scan_req->chan_list[i].scan_type =
MWIFIEX_SCAN_TYPE_PASSIVE;
else
- scan_req.chan_list[i].scan_type =
+ scan_req->chan_list[i].scan_type =
MWIFIEX_SCAN_TYPE_ACTIVE;
- scan_req.chan_list[i].scan_time = 0;
+ scan_req->chan_list[i].scan_time = 0;
}
- if (mwifiex_set_user_scan_ioctl(priv, &scan_req)) {
+ if (mwifiex_set_user_scan_ioctl(priv, scan_req)) {
ret = -EFAULT;
goto done;
}
@@ -1491,6 +1497,7 @@ done:
cfg80211_scan_done(priv->scan_request,
(priv->scan_result_status < 0));
priv->scan_request = NULL;
+ kfree(scan_req);
}
if (priv->assoc_request) {
--
1.7.0.2
next prev parent reply other threads:[~2011-03-11 0:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-11 0:25 [PATCH 1/4] mwifiex: remove unnecessory external function declarations Bing Zhao
2011-03-11 0:25 ` Bing Zhao [this message]
2011-03-11 0:25 ` [PATCH 3/4] mwifiex: remove ieee.h Bing Zhao
2011-03-11 0:25 ` [PATCH 4/4] mwifiex: remove unused macros Bing Zhao
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=1299803149-25996-2-git-send-email-bzhao@marvell.com \
--to=bzhao@marvell.com \
--cc=akarwar@marvell.com \
--cc=dkiran@marvell.com \
--cc=frankh@marvell.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=yangyang@marvell.com \
--cc=yogeshp@marvell.com \
/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).