Skip to content

Commit

Permalink
usb: usbtest: reduce stack usage in test_queue
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bixuan Cui authored and Greg Kroah-Hartman committed Jul 21, 2020
1 parent 6e1c224 commit a482766
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/usb/misc/usbtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2043,14 +2043,18 @@ 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;

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;
Expand Down Expand Up @@ -2137,13 +2141,17 @@ 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:
for (i = 0; i < param->sglen; i++) {
if (urbs[i])
simple_free_urb(urbs[i]);
}

kfree(urbs);
return status;
}

Expand Down

0 comments on commit a482766

Please sign in to comment.