qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 13/23] hw/usb/hcd-xhci: Avoid dynamic stack allocation


From: Philippe Mathieu-Daudé
Subject: [PATCH 13/23] hw/usb/hcd-xhci: Avoid dynamic stack allocation
Date: Wed, 5 May 2021 23:10:37 +0200

Use autofree heap allocation instead of variable-length
array on the stack.

Signed-off-by: Philippe Mathieu-Daudé <philmd@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);
 
     DPRINTF("xhci_get_port_bandwidth()\n");
 
-- 
2.26.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]