Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: usbtest: reduce stack usage in test_queue

Fix the warning: [-Werror=-Wframe-larger-than=]

drivers/usb/misc/usbtest.c: In function 'test_queue':
drivers/usb/misc/usbtest.c:2148:1:
warning: the frame size of 1232 bytes is larger than 1024 bytes

Reported-by: kbuild test robot <lkp@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
Link: https://lore.kernel.org/r/ffa85702-86ab-48d7-4da2-2efcc94b05d3@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bixuan Cui and committed by
Greg Kroah-Hartman
a482766d 6e1c2241

+9 -1
+9 -1
drivers/usb/misc/usbtest.c
··· 2043 2043 unsigned i; 2044 2044 unsigned long packets = 0; 2045 2045 int status = 0; 2046 - struct urb *urbs[MAX_SGLEN]; 2046 + struct urb **urbs; 2047 2047 2048 2048 if (!param->sglen || param->iterations > UINT_MAX / param->sglen) 2049 2049 return -EINVAL; 2050 2050 2051 2051 if (param->sglen > MAX_SGLEN) 2052 2052 return -EINVAL; 2053 + 2054 + urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL); 2055 + if (!urbs) 2056 + return -ENOMEM; 2053 2057 2054 2058 memset(&context, 0, sizeof(context)); 2055 2059 context.count = param->iterations * param->sglen; ··· 2141 2137 else if (context.errors > 2142 2138 (context.is_iso ? context.packet_count / 10 : 0)) 2143 2139 status = -EIO; 2140 + 2141 + kfree(urbs); 2144 2142 return status; 2145 2143 2146 2144 fail: ··· 2150 2144 if (urbs[i]) 2151 2145 simple_free_urb(urbs[i]); 2152 2146 } 2147 + 2148 + kfree(urbs); 2153 2149 return status; 2154 2150 } 2155 2151