On 5/5/21 2:10 PM, Philippe Mathieu-Daudé wrote:
Use autofree heap allocation instead of variable-length
array on the stack.
Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com>
---
hw/usb/hcd-xhci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 7acfb8137bc..59a267e3c8b 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -2387,7 +2387,7 @@ static void xhci_detach_slot(XHCIState *xhci, USBPort
*uport)
static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)
{
dma_addr_t ctx;
- uint8_t bw_ctx[xhci->numports+1];
+ g_autofree uint8_t *bw_ctx = g_malloc(xhci->numports + 1);
There is a later use of sizeof(bw_ctx), which is now broken.
Also, I think you might as well remove this buffer entirely and use the address
space memset routine you recently added.
r~