Skip to content

Commit

Permalink
staging: rtl8723bs: reduce stack usage of cfg80211_rtw_scan
Browse files Browse the repository at this point in the history
The build of xtensa allmodconfig gives warning of:
In function 'cfg80211_rtw_scan':
warning: the frame size of 1040 bytes is larger than 1024 bytes

Allocate memory for ssid dynamically to reduce the stack usage, as an
added benifit we can remove the memset by using kzalloc while allocating
memory.

Signed-off-by: Sudip Mukherjee <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and gregkh committed Oct 25, 2019
1 parent 9f665d8 commit f306bde
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
int i;
u8 _status = false;
int ret = 0;
struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
struct ndis_802_11_ssid *ssid = NULL;
struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
u8 survey_times =3;
u8 survey_times_for_one_ch =6;
Expand Down Expand Up @@ -1604,7 +1604,13 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
goto check_need_indicate_scan_done;
}

memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT);
ssid = kzalloc(RTW_SSID_SCAN_AMOUNT * sizeof(struct ndis_802_11_ssid),
GFP_KERNEL);
if (!ssid) {
ret = -ENOMEM;
goto check_need_indicate_scan_done;
}

/* parsing request ssids, n_ssids */
for (i = 0; i < request->n_ssids && i < RTW_SSID_SCAN_AMOUNT; i++) {
#ifdef DEBUG_CFG80211
Expand Down Expand Up @@ -1648,6 +1654,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
}

check_need_indicate_scan_done:
kfree(ssid);
if (need_indicate_scan_done)
{
rtw_cfg80211_surveydone_event_callback(padapter);
Expand Down

0 comments on commit f306bde

Please sign in to comment.