[PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap

From: Lee Jones
Date: Wed May 26 2021 - 09:02:32 EST


Fixes the following W=1 kernel build warning(s):

drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Cc: Mathias Nyman <mathias.nyman@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: linux-usb@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee.jones@xxxxxxxxxx>
---
drivers/usb/host/xhci.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index ac2a7d4288883..40ce4b4eb12ad 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2773,7 +2773,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
struct xhci_virt_device *virt_dev,
struct xhci_container_ctx *in_ctx)
{
- struct xhci_bw_info ep_bw_info[31];
+ struct xhci_bw_info *ep_bw_info;
int i;
struct xhci_input_control_ctx *ctrl_ctx;
int old_active_eps = 0;
@@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
return -ENOMEM;
}

+ ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
+ if (!ep_bw_info)
+ return -ENOMEM;
+
for (i = 0; i < 31; i++) {
if (!EP_IS_ADDED(ctrl_ctx, i) && !EP_IS_DROPPED(ctrl_ctx, i))
continue;
@@ -2824,6 +2828,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
* Update the number of active TTs.
*/
xhci_update_tt_active_eps(xhci, virt_dev, old_active_eps);
+ kfree(ep_bw_info);
return 0;
}

@@ -2855,6 +2860,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
&virt_dev->eps[i],
virt_dev->tt_info);
}
+ kfree(ep_bw_info);
return -ENOMEM;
}

--
2.31.1