ChangeSet 1.1143.1.6, 2003/03/19 15:41:50-08:00, randy.dunlap@verizon.net [PATCH] USB: reduce stack usage in cdc-ether This patch to 2.5.64 reduces the large stack usage in log_device_info() [and makes it static to boot]. drivers/usb/net/cdc-ether.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff -Nru a/drivers/usb/net/cdc-ether.c b/drivers/usb/net/cdc-ether.c --- a/drivers/usb/net/cdc-ether.c Thu Mar 20 15:03:43 2003 +++ b/drivers/usb/net/cdc-ether.c Thu Mar 20 15:03:43 2003 @@ -1064,15 +1064,23 @@ // Used by driver's probe routine //////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -void log_device_info(ether_dev_t *ether_dev) +static void log_device_info(ether_dev_t *ether_dev) { int len; int string_num; - unsigned char manu[256]; - unsigned char prod[256]; - unsigned char sern[256]; + unsigned char *manu = NULL; + unsigned char *prod = NULL; + unsigned char *sern = NULL; unsigned char *mac_addr; + manu = kmalloc(256, GFP_KERNEL); + prod = kmalloc(256, GFP_KERNEL); + sern = kmalloc(256, GFP_KERNEL); + if (!manu || !prod || !sern) { + dbg("no mem for log_device_info"); + goto fini; + } + // Default empty strings in case we don't find a real one manu[0] = 0x00; prod[0] = 0x00; @@ -1113,6 +1121,10 @@ ether_dev->net->name, manu, prod, sern, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5] ); +fini: + kfree(manu); + kfree(prod); + kfree(sern); } /* Forward declaration */