From: Marc-André Lureau Date: Fri, 15 Jul 2016 09:14:07 +0000 (+0200) Subject: usb: free USBDevice.strings X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ec507f112361ddf6dac0f0a30e84d9da1b4910b6;p=qemu.git usb: free USBDevice.strings 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 Reviewed-by: Gerd Hoffmann --- diff --git a/hw/usb/bus.c b/hw/usb/bus.c index c28ccb8a96..25913ad488 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -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);