Commit 7909a590 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Kalle Valo

airo: work around stack usage warning

gcc-11 with KASAN on 32-bit arm produces a warning about a function
that needs a lot of stack space:

drivers/net/wireless/cisco/airo.c: In function 'setup_card.constprop':
drivers/net/wireless/cisco/airo.c:3960:1: error: the frame size of 1512 bytes is larger than 1400 bytes [-Werror=frame-larger-than=]

Most of this is from a single large structure that could be dynamically
allocated or moved into the per-device structure.  However, as the callers
all seem to have a fairly well bounded call chain, the easiest change
is to pull out the part of the function that needs the large variables
into a separate function and mark that as noinline_for_stack. This does
not reduce the total stack usage, but it gets rid of the warning and
requires minimal changes otherwise.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210323131634.2669455-1-arnd@kernel.org
parent 7b0e2c4f
...@@ -3817,53 +3817,12 @@ static inline void set_auth_type(struct airo_info *local, int auth_type) ...@@ -3817,53 +3817,12 @@ static inline void set_auth_type(struct airo_info *local, int auth_type)
local->last_auth = auth_type; local->last_auth = auth_type;
} }
static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) static int noinline_for_stack airo_readconfig(struct airo_info *ai, u8 *mac, int lock)
{ {
Cmd cmd; int i, status;
Resp rsp; /* large variables, so don't inline this function,
int status; * maybe change to kmalloc
SsidRid mySsid; */
__le16 lastindex;
WepKeyRid wkr;
int rc;
memset(&mySsid, 0, sizeof(mySsid));
kfree (ai->flash);
ai->flash = NULL;
/* The NOP is the first step in getting the card going */
cmd.cmd = NOP;
cmd.parm0 = cmd.parm1 = cmd.parm2 = 0;
if (lock && down_interruptible(&ai->sem))
return ERROR;
if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) {
if (lock)
up(&ai->sem);
return ERROR;
}
disable_MAC(ai, 0);
// Let's figure out if we need to use the AUX port
if (!test_bit(FLAG_MPI,&ai->flags)) {
cmd.cmd = CMD_ENABLEAUX;
if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) {
if (lock)
up(&ai->sem);
airo_print_err(ai->dev->name, "Error checking for AUX port");
return ERROR;
}
if (!aux_bap || rsp.status & 0xff00) {
ai->bap_read = fast_bap_read;
airo_print_dbg(ai->dev->name, "Doing fast bap_reads");
} else {
ai->bap_read = aux_bap_read;
airo_print_dbg(ai->dev->name, "Doing AUX bap_reads");
}
}
if (lock)
up(&ai->sem);
if (ai->config.len == 0) {
int i;
tdsRssiRid rssi_rid; tdsRssiRid rssi_rid;
CapabilityRid cap_rid; CapabilityRid cap_rid;
...@@ -3876,7 +3835,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3876,7 +3835,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
status = readCapabilityRid(ai, &cap_rid, lock); status = readCapabilityRid(ai, &cap_rid, lock);
if (status != SUCCESS) return ERROR; if (status != SUCCESS) return ERROR;
status = PC4500_readrid(ai, RID_RSSI,&rssi_rid, sizeof(rssi_rid), lock); status = PC4500_readrid(ai, RID_RSSI, &rssi_rid, sizeof(rssi_rid), lock);
if (status == SUCCESS) { if (status == SUCCESS) {
if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL)
memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */ memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */
...@@ -3915,6 +3874,60 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) ...@@ -3915,6 +3874,60 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
} }
} }
set_bit (FLAG_COMMIT, &ai->flags); set_bit (FLAG_COMMIT, &ai->flags);
return SUCCESS;
}
static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
{
Cmd cmd;
Resp rsp;
int status;
SsidRid mySsid;
__le16 lastindex;
WepKeyRid wkr;
int rc;
memset(&mySsid, 0, sizeof(mySsid));
kfree (ai->flash);
ai->flash = NULL;
/* The NOP is the first step in getting the card going */
cmd.cmd = NOP;
cmd.parm0 = cmd.parm1 = cmd.parm2 = 0;
if (lock && down_interruptible(&ai->sem))
return ERROR;
if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) {
if (lock)
up(&ai->sem);
return ERROR;
}
disable_MAC(ai, 0);
// Let's figure out if we need to use the AUX port
if (!test_bit(FLAG_MPI,&ai->flags)) {
cmd.cmd = CMD_ENABLEAUX;
if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) {
if (lock)
up(&ai->sem);
airo_print_err(ai->dev->name, "Error checking for AUX port");
return ERROR;
}
if (!aux_bap || rsp.status & 0xff00) {
ai->bap_read = fast_bap_read;
airo_print_dbg(ai->dev->name, "Doing fast bap_reads");
} else {
ai->bap_read = aux_bap_read;
airo_print_dbg(ai->dev->name, "Doing AUX bap_reads");
}
}
if (lock)
up(&ai->sem);
if (ai->config.len == 0) {
status = airo_readconfig(ai, mac, lock);
if (status != SUCCESS)
return ERROR;
} }
/* Setup the SSIDs if present */ /* Setup the SSIDs if present */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment