usb/hid: avoid dynamic stack allocation
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 3 May 2021 13:29:11 +0000 (15:29 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 4 May 2021 06:38:23 +0000 (08:38 +0200)
Use autofree heap allocation instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210503132915.2335822-2-kraxel@redhat.com>

hw/usb/dev-hid.c
hw/usb/dev-wacom.c

index fc39bab79f94b0a0d06c23fc650d1fc21bf4647e..1c7ae97c3033442dba820db492bdd04cba7c6299 100644 (file)
@@ -656,7 +656,7 @@ static void usb_hid_handle_data(USBDevice *dev, USBPacket *p)
 {
     USBHIDState *us = USB_HID(dev);
     HIDState *hs = &us->hid;
-    uint8_t buf[p->iov.size];
+    g_autofree uint8_t *buf = g_malloc(p->iov.size);
     int len = 0;
 
     switch (p->pid) {
index b595048635090242b5e771a11436e623305a113f..ed687bc9f1eb1b20b7e8ab0db35ac6cdb4d6b5fc 100644 (file)
@@ -301,7 +301,7 @@ static void usb_wacom_handle_control(USBDevice *dev, USBPacket *p,
 static void usb_wacom_handle_data(USBDevice *dev, USBPacket *p)
 {
     USBWacomState *s = (USBWacomState *) dev;
-    uint8_t buf[p->iov.size];
+    g_autofree uint8_t *buf = g_malloc(p->iov.size);
     int len = 0;
 
     switch (p->pid) {