aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBixuan Cui2020-07-17 08:22:53 +0800
committerGreg Kroah-Hartman2020-07-21 13:41:57 +0200
commita482766d008556c2f4976cf6096a4887da070f27 (patch)
tree7ccf59368b0fe415ff9604b52b84774d2d56e965
parent6e1c2241f4cecfc21f26f44179d04217c8390338 (diff)
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>
-rw-r--r--drivers/usb/misc/usbtest.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 8b220d56647b..150090ee4ec1 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
unsigned i;
unsigned long packets = 0;
int status = 0;
- struct urb *urbs[MAX_SGLEN];
+ struct urb **urbs;
if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
return -EINVAL;
@@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
if (param->sglen > MAX_SGLEN)
return -EINVAL;
+ urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL);
+ if (!urbs)
+ return -ENOMEM;
+
memset(&context, 0, sizeof(context));
context.count = param->iterations * param->sglen;
context.dev = dev;
@@ -2137,6 +2141,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
else if (context.errors >
(context.is_iso ? context.packet_count / 10 : 0))
status = -EIO;
+
+ kfree(urbs);
return status;
fail:
@@ -2144,6 +2150,8 @@ fail:
if (urbs[i])
simple_free_urb(urbs[i]);
}
+
+ kfree(urbs);
return status;
}