qemu-ppc
[Top][All Lists]
Advanced

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

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


From: Richard Henderson
Subject: Re: [PATCH 13/23] hw/usb/hcd-xhci: Avoid dynamic stack allocation
Date: Fri, 7 May 2021 09:34:39 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

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é <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);


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~



reply via email to

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