usb: free USBDevice.strings
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Fri, 15 Jul 2016 09:14:07 +0000 (11:14 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Sun, 7 Aug 2016 20:00:32 +0000 (00:00 +0400)
The list is created during instance init and further populated with
usb_desc_set_string(). Clear it when unrealizing the device.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/bus.c

index c28ccb8..25913ad 100644 (file)
@@ -279,6 +279,13 @@ static void usb_qdev_realize(DeviceState *qdev, Error **errp)
 static void usb_qdev_unrealize(DeviceState *qdev, Error **errp)
 {
     USBDevice *dev = USB_DEVICE(qdev);
+    USBDescString *s, *next;
+
+    QLIST_FOREACH_SAFE(s, &dev->strings, next, next) {
+        QLIST_REMOVE(s, next);
+        g_free(s->str);
+        g_free(s);
+    }
 
     if (dev->attached) {
         usb_device_detach(dev);