staging: reduce stack usage in prism2fw.c
Fix frame size (stack usage) warning by allocating and freeing pointers to the data. drivers/staging/wlan-ng/prism2fw.c:1115:1: warning: the frame size of 4288 bytes is larger than 2048 bytes Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bcc66c0b88
commit
c90e3e80b9
1 changed files with 69 additions and 55 deletions
|
@ -982,9 +982,8 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
|
||||||
unsigned int nfchunks)
|
unsigned int nfchunks)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
struct p80211msg_p2req_ramdl_state rstatemsg;
|
struct p80211msg_p2req_ramdl_state *rstmsg;
|
||||||
struct p80211msg_p2req_ramdl_write rwritemsg;
|
struct p80211msg_p2req_ramdl_write *rwrmsg;
|
||||||
struct p80211msg *msgp;
|
|
||||||
u32 resultcode;
|
u32 resultcode;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -993,57 +992,68 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
|
||||||
u32 currlen;
|
u32 currlen;
|
||||||
u32 currdaddr;
|
u32 currdaddr;
|
||||||
|
|
||||||
/* Initialize the messages */
|
rstmsg = kmalloc(sizeof(*rstmsg), GFP_KERNEL);
|
||||||
memset(&rstatemsg, 0, sizeof(rstatemsg));
|
rwrmsg = kmalloc(sizeof(*rwrmsg), GFP_KERNEL);
|
||||||
strcpy(rstatemsg.devname, wlandev->name);
|
if (!rstmsg || !rwrmsg) {
|
||||||
rstatemsg.msgcode = DIDmsg_p2req_ramdl_state;
|
kfree(rstmsg);
|
||||||
rstatemsg.msglen = sizeof(rstatemsg);
|
kfree(rwrmsg);
|
||||||
rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable;
|
printk(KERN_ERR
|
||||||
rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
|
"writeimage: no memory for firmware download, "
|
||||||
rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
|
"aborting download\n");
|
||||||
rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok;
|
return -ENOMEM;
|
||||||
rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok;
|
}
|
||||||
rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
|
|
||||||
rstatemsg.enable.len = sizeof(u32);
|
|
||||||
rstatemsg.exeaddr.len = sizeof(u32);
|
|
||||||
rstatemsg.resultcode.len = sizeof(u32);
|
|
||||||
|
|
||||||
memset(&rwritemsg, 0, sizeof(rwritemsg));
|
/* Initialize the messages */
|
||||||
strcpy(rwritemsg.devname, wlandev->name);
|
memset(rstmsg, 0, sizeof(*rstmsg));
|
||||||
rwritemsg.msgcode = DIDmsg_p2req_ramdl_write;
|
strcpy(rstmsg->devname, wlandev->name);
|
||||||
rwritemsg.msglen = sizeof(rwritemsg);
|
rstmsg->msgcode = DIDmsg_p2req_ramdl_state;
|
||||||
rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr;
|
rstmsg->msglen = sizeof(*rstmsg);
|
||||||
rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len;
|
rstmsg->enable.did = DIDmsg_p2req_ramdl_state_enable;
|
||||||
rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data;
|
rstmsg->exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
|
||||||
rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
|
rstmsg->resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
|
||||||
rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok;
|
rstmsg->enable.status = P80211ENUM_msgitem_status_data_ok;
|
||||||
rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok;
|
rstmsg->exeaddr.status = P80211ENUM_msgitem_status_data_ok;
|
||||||
rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok;
|
rstmsg->resultcode.status = P80211ENUM_msgitem_status_no_value;
|
||||||
rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
|
rstmsg->enable.len = sizeof(u32);
|
||||||
rwritemsg.addr.len = sizeof(u32);
|
rstmsg->exeaddr.len = sizeof(u32);
|
||||||
rwritemsg.len.len = sizeof(u32);
|
rstmsg->resultcode.len = sizeof(u32);
|
||||||
rwritemsg.data.len = WRITESIZE_MAX;
|
|
||||||
rwritemsg.resultcode.len = sizeof(u32);
|
memset(rwrmsg, 0, sizeof(*rwrmsg));
|
||||||
|
strcpy(rwrmsg->devname, wlandev->name);
|
||||||
|
rwrmsg->msgcode = DIDmsg_p2req_ramdl_write;
|
||||||
|
rwrmsg->msglen = sizeof(*rwrmsg);
|
||||||
|
rwrmsg->addr.did = DIDmsg_p2req_ramdl_write_addr;
|
||||||
|
rwrmsg->len.did = DIDmsg_p2req_ramdl_write_len;
|
||||||
|
rwrmsg->data.did = DIDmsg_p2req_ramdl_write_data;
|
||||||
|
rwrmsg->resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
|
||||||
|
rwrmsg->addr.status = P80211ENUM_msgitem_status_data_ok;
|
||||||
|
rwrmsg->len.status = P80211ENUM_msgitem_status_data_ok;
|
||||||
|
rwrmsg->data.status = P80211ENUM_msgitem_status_data_ok;
|
||||||
|
rwrmsg->resultcode.status = P80211ENUM_msgitem_status_no_value;
|
||||||
|
rwrmsg->addr.len = sizeof(u32);
|
||||||
|
rwrmsg->len.len = sizeof(u32);
|
||||||
|
rwrmsg->data.len = WRITESIZE_MAX;
|
||||||
|
rwrmsg->resultcode.len = sizeof(u32);
|
||||||
|
|
||||||
/* Send xxx_state(enable) */
|
/* Send xxx_state(enable) */
|
||||||
pr_debug("Sending dl_state(enable) message.\n");
|
pr_debug("Sending dl_state(enable) message.\n");
|
||||||
rstatemsg.enable.data = P80211ENUM_truth_true;
|
rstmsg->enable.data = P80211ENUM_truth_true;
|
||||||
rstatemsg.exeaddr.data = startaddr;
|
rstmsg->exeaddr.data = startaddr;
|
||||||
|
|
||||||
msgp = (struct p80211msg *) &rstatemsg;
|
result = prism2mgmt_ramdl_state(wlandev, rstmsg);
|
||||||
result = prism2mgmt_ramdl_state(wlandev, msgp);
|
|
||||||
if (result) {
|
if (result) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"writeimage state enable failed w/ result=%d, "
|
"writeimage state enable failed w/ result=%d, "
|
||||||
"aborting download\n", result);
|
"aborting download\n", result);
|
||||||
return result;
|
goto free_result;
|
||||||
}
|
}
|
||||||
resultcode = rstatemsg.resultcode.data;
|
resultcode = rstmsg->resultcode.data;
|
||||||
if (resultcode != P80211ENUM_resultcode_success) {
|
if (resultcode != P80211ENUM_resultcode_success) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"writeimage()->xxxdl_state msg indicates failure, "
|
"writeimage()->xxxdl_state msg indicates failure, "
|
||||||
"w/ resultcode=%d, aborting download.\n", resultcode);
|
"w/ resultcode=%d, aborting download.\n", resultcode);
|
||||||
return 1;
|
result = 1;
|
||||||
|
goto free_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now, loop through the data chunks and send WRITESIZE_MAX data */
|
/* Now, loop through the data chunks and send WRITESIZE_MAX data */
|
||||||
|
@ -1061,9 +1071,9 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
|
||||||
curroff = j * WRITESIZE_MAX;
|
curroff = j * WRITESIZE_MAX;
|
||||||
currdaddr = fchunk[i].addr + curroff;
|
currdaddr = fchunk[i].addr + curroff;
|
||||||
/* Setup the message */
|
/* Setup the message */
|
||||||
rwritemsg.addr.data = currdaddr;
|
rwrmsg->addr.data = currdaddr;
|
||||||
rwritemsg.len.data = currlen;
|
rwrmsg->len.data = currlen;
|
||||||
memcpy(rwritemsg.data.data,
|
memcpy(rwrmsg->data.data,
|
||||||
fchunk[i].data + curroff, currlen);
|
fchunk[i].data + curroff, currlen);
|
||||||
|
|
||||||
/* Send flashdl_write(pda) */
|
/* Send flashdl_write(pda) */
|
||||||
|
@ -1071,23 +1081,23 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
|
||||||
("Sending xxxdl_write message addr=%06x len=%d.\n",
|
("Sending xxxdl_write message addr=%06x len=%d.\n",
|
||||||
currdaddr, currlen);
|
currdaddr, currlen);
|
||||||
|
|
||||||
msgp = (struct p80211msg *) &rwritemsg;
|
result = prism2mgmt_ramdl_write(wlandev, rwrmsg);
|
||||||
result = prism2mgmt_ramdl_write(wlandev, msgp);
|
|
||||||
|
|
||||||
/* Check the results */
|
/* Check the results */
|
||||||
if (result) {
|
if (result) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"writeimage chunk write failed w/ result=%d, "
|
"writeimage chunk write failed w/ result=%d, "
|
||||||
"aborting download\n", result);
|
"aborting download\n", result);
|
||||||
return result;
|
goto free_result;
|
||||||
}
|
}
|
||||||
resultcode = rstatemsg.resultcode.data;
|
resultcode = rstmsg->resultcode.data;
|
||||||
if (resultcode != P80211ENUM_resultcode_success) {
|
if (resultcode != P80211ENUM_resultcode_success) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"writeimage()->xxxdl_write msg indicates failure, "
|
"writeimage()->xxxdl_write msg indicates failure, "
|
||||||
"w/ resultcode=%d, aborting download.\n",
|
"w/ resultcode=%d, aborting download.\n",
|
||||||
resultcode);
|
resultcode);
|
||||||
return 1;
|
result = 1;
|
||||||
|
goto free_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1095,24 +1105,28 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
|
||||||
|
|
||||||
/* Send xxx_state(disable) */
|
/* Send xxx_state(disable) */
|
||||||
pr_debug("Sending dl_state(disable) message.\n");
|
pr_debug("Sending dl_state(disable) message.\n");
|
||||||
rstatemsg.enable.data = P80211ENUM_truth_false;
|
rstmsg->enable.data = P80211ENUM_truth_false;
|
||||||
rstatemsg.exeaddr.data = 0;
|
rstmsg->exeaddr.data = 0;
|
||||||
|
|
||||||
msgp = (struct p80211msg *) &rstatemsg;
|
result = prism2mgmt_ramdl_state(wlandev, rstmsg);
|
||||||
result = prism2mgmt_ramdl_state(wlandev, msgp);
|
|
||||||
if (result) {
|
if (result) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"writeimage state disable failed w/ result=%d, "
|
"writeimage state disable failed w/ result=%d, "
|
||||||
"aborting download\n", result);
|
"aborting download\n", result);
|
||||||
return result;
|
goto free_result;
|
||||||
}
|
}
|
||||||
resultcode = rstatemsg.resultcode.data;
|
resultcode = rstmsg->resultcode.data;
|
||||||
if (resultcode != P80211ENUM_resultcode_success) {
|
if (resultcode != P80211ENUM_resultcode_success) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"writeimage()->xxxdl_state msg indicates failure, "
|
"writeimage()->xxxdl_state msg indicates failure, "
|
||||||
"w/ resultcode=%d, aborting download.\n", resultcode);
|
"w/ resultcode=%d, aborting download.\n", resultcode);
|
||||||
return 1;
|
result = 1;
|
||||||
|
goto free_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_result:
|
||||||
|
kfree(rstmsg);
|
||||||
|
kfree(rwrmsg);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue