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

[Xen-changelog] [qemu-xen master] usbredir: free vm_change_state_handler in usbredir destroy dispatch



commit 07b026fd82d6cf11baf7d7c603c4f5f6070b35bf
Author:     Li Qiang <liqiang6-s@xxxxxx>
AuthorDate: Mon Nov 7 21:57:46 2016 -0800
Commit:     Stefan Hajnoczi <stefanha@xxxxxxxxxx>
CommitDate: Thu Nov 10 15:29:58 2016 +0000

    usbredir: free vm_change_state_handler in usbredir destroy dispatch
    
    In usbredir destroy dispatch function, it doesn't free the vm change
    state handler once registered in usbredir_realize function. This will
    lead a memory leak issue. This patch avoid this.
    
    Signed-off-by: Li Qiang <liqiang6-s@xxxxxx>
    Reviewed-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
    Message-id: 58216976.d0236b0a.77b99.bcd6@xxxxxxxxxxxxx
    Signed-off-by: Gerd Hoffmann <kraxel@xxxxxxxxxx>
---
 hw/usb/redirect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 528081e..a657237 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -132,6 +132,7 @@ struct USBRedirDevice {
     struct usbredirfilter_rule *filter_rules;
     int filter_rules_count;
     int compatible_speedmask;
+    VMChangeStateEntry *vmstate;
 };
 
 #define TYPE_USB_REDIR "usb-redir"
@@ -1411,7 +1412,8 @@ static void usbredir_realize(USBDevice *udev, Error 
**errp)
                              usbredir_chardev_read, usbredir_chardev_event,
                              dev, NULL, true);
 
-    qemu_add_vm_change_state_handler(usbredir_vm_state_change, dev);
+    dev->vmstate =
+        qemu_add_vm_change_state_handler(usbredir_vm_state_change, dev);
 }
 
 static void usbredir_cleanup_device_queues(USBRedirDevice *dev)
@@ -1450,6 +1452,7 @@ static void usbredir_handle_destroy(USBDevice *udev)
     }
 
     free(dev->filter_rules);
+    qemu_del_vm_change_state_handler(dev->vmstate);
 }
 
 static int usbredir_check_filter(USBRedirDevice *dev)
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.