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

usb: usbtest: Remove stack VLA usage

The kernel would like to have all stack VLA usage removed[1]. We
already have a pre-processor constant defined MAX_SGLEN. We can use
this instead of the variable param-sglen.

[1]: https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Tobin C. Harding and committed by
Greg Kroah-Hartman
c53439fb cc9debf8

+4 -1
+4 -1
drivers/usb/misc/usbtest.c
··· 2028 2028 unsigned i; 2029 2029 unsigned long packets = 0; 2030 2030 int status = 0; 2031 - struct urb *urbs[param->sglen]; 2031 + struct urb *urbs[MAX_SGLEN]; 2032 2032 2033 2033 if (!param->sglen || param->iterations > UINT_MAX / param->sglen) 2034 + return -EINVAL; 2035 + 2036 + if (param->sglen > MAX_SGLEN) 2034 2037 return -EINVAL; 2035 2038 2036 2039 memset(&context, 0, sizeof(context));