summaryrefslogtreecommitdiff
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavoars@kernel.org>2022-01-21 01:20:43 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-01-26 16:01:59 +0300
commit7643fd78e1467642757224bd9c39b4bce4422e50 (patch)
tree7f7bd093b8593df034c4d5d60d5da16afd7a5fa6 /drivers/usb/host
parentc89686118c786a523eee3ef68ed38330319626d8 (diff)
downloadlinux-7643fd78e1467642757224bd9c39b4bce4422e50.tar.xz
usb: host: fotg210: Use struct_size() helper in kzalloc()
Make use of the struct_size() helper instead of an open-coded version, in order to avoid any potential type mistakes or integer overflows that, in the worst scenario, could lead to heap overflows. Also, address the following sparse warnings: drivers/usb/host/fotg210-hcd.c:4017:20: warning: using sizeof on a flexible structure Link: https://github.com/KSPP/linux/issues/174 Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20220120222043.GA33559@embeddedor Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/fotg210-hcd.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 7af17c8e069b..c3fd375b4778 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -4014,10 +4014,8 @@ static struct fotg210_iso_sched *iso_sched_alloc(unsigned packets,
gfp_t mem_flags)
{
struct fotg210_iso_sched *iso_sched;
- int size = sizeof(*iso_sched);
- size += packets * sizeof(struct fotg210_iso_packet);
- iso_sched = kzalloc(size, mem_flags);
+ iso_sched = kzalloc(struct_size(iso_sched, packet, packets), mem_flags);
if (likely(iso_sched != NULL))
INIT_LIST_HEAD(&iso_sched->td_list);