Commit c90e3e80 authored by Randy Dunlap's avatar Randy Dunlap Committed by Greg Kroah-Hartman

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: default avatarRandy Dunlap <rdunlap@xenotime.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bcc66c0b
...@@ -982,9 +982,8 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, ...@@ -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, ...@@ -993,57 +992,68 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
u32 currlen; u32 currlen;
u32 currdaddr; u32 currdaddr;
rstmsg = kmalloc(sizeof(*rstmsg), GFP_KERNEL);
rwrmsg = kmalloc(sizeof(*rwrmsg), GFP_KERNEL);
if (!rstmsg || !rwrmsg) {
kfree(rstmsg);
kfree(rwrmsg);
printk(KERN_ERR
"writeimage: no memory for firmware download, "
"aborting download\n");
return -ENOMEM;
}
/* Initialize the messages */ /* Initialize the messages */
memset(&rstatemsg, 0, sizeof(rstatemsg)); memset(rstmsg, 0, sizeof(*rstmsg));
strcpy(rstatemsg.devname, wlandev->name); strcpy(rstmsg->devname, wlandev->name);
rstatemsg.msgcode = DIDmsg_p2req_ramdl_state; rstmsg->msgcode = DIDmsg_p2req_ramdl_state;
rstatemsg.msglen = sizeof(rstatemsg); rstmsg->msglen = sizeof(*rstmsg);
rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable; rstmsg->enable.did = DIDmsg_p2req_ramdl_state_enable;
rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr; rstmsg->exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode; rstmsg->resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok; rstmsg->enable.status = P80211ENUM_msgitem_status_data_ok;
rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok; rstmsg->exeaddr.status = P80211ENUM_msgitem_status_data_ok;
rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value; rstmsg->resultcode.status = P80211ENUM_msgitem_status_no_value;
rstatemsg.enable.len = sizeof(u32); rstmsg->enable.len = sizeof(u32);
rstatemsg.exeaddr.len = sizeof(u32); rstmsg->exeaddr.len = sizeof(u32);
rstatemsg.resultcode.len = sizeof(u32); rstmsg->resultcode.len = sizeof(u32);
memset(&rwritemsg, 0, sizeof(rwritemsg)); memset(rwrmsg, 0, sizeof(*rwrmsg));
strcpy(rwritemsg.devname, wlandev->name); strcpy(rwrmsg->devname, wlandev->name);
rwritemsg.msgcode = DIDmsg_p2req_ramdl_write; rwrmsg->msgcode = DIDmsg_p2req_ramdl_write;
rwritemsg.msglen = sizeof(rwritemsg); rwrmsg->msglen = sizeof(*rwrmsg);
rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr; rwrmsg->addr.did = DIDmsg_p2req_ramdl_write_addr;
rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len; rwrmsg->len.did = DIDmsg_p2req_ramdl_write_len;
rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data; rwrmsg->data.did = DIDmsg_p2req_ramdl_write_data;
rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode; rwrmsg->resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok; rwrmsg->addr.status = P80211ENUM_msgitem_status_data_ok;
rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok; rwrmsg->len.status = P80211ENUM_msgitem_status_data_ok;
rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok; rwrmsg->data.status = P80211ENUM_msgitem_status_data_ok;
rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value; rwrmsg->resultcode.status = P80211ENUM_msgitem_status_no_value;
rwritemsg.addr.len = sizeof(u32); rwrmsg->addr.len = sizeof(u32);
rwritemsg.len.len = sizeof(u32); rwrmsg->len.len = sizeof(u32);
rwritemsg.data.len = WRITESIZE_MAX; rwrmsg->data.len = WRITESIZE_MAX;
rwritemsg.resultcode.len = sizeof(u32); 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, ...@@ -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, ...@@ -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, ...@@ -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;
} }
......
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