Skip to contentSkip to conversation

usb: two memory leak fixes.

GIT PULL Applied Gerd Hoffmann 2 participants 4 messages Nov 9, 2016 – Nov 10, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

Here is the usb patch queue, fixing two memory leaks.

please pull,
Gerd

The following changes since commit 207faf24c58859f5240f66bf6decc33b87a1776e:

Merge remote-tracking branch 'pm215/tags/pull-target-arm-20161107' into staging (2016-11-07 14:02:15 +0000)

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-usb-20161109-1

for you to fetch changes up to f0bf4999eae156142a86290fda45de4094e3e8b4:

usbredir: free vm_change_state_handler in usbredir destroy dispatch (2016-11-08 15:01:23 +0100)

----------------------------------------------------------------
usb: two memory leak fixes.

----------------------------------------------------------------
Li Qiang (2):
usb: ehci: fix memory leak in ehci_init_transfer
usbredir: free vm_change_state_handler in usbredir destroy dispatch

 hw/usb/hcd-ehci.c | 1 +
 hw/usb/redirect.c | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
#1 lore raw

[Qemu-devel] [PULL 1/2] usb: ehci: fix memory leak in ehci_init_transfer

From: Li Qiang <[email protected]>

In ehci_init_transfer function, if the 'cpage' is bigger than 4, it doesn't free the 'p->sgl' once allocated previously thus leading a memory leak issue. This patch avoid this.

Message-id: [email protected]

---
 hw/usb/hcd-ehci.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/hcd-ehci.c +1 -0
index f4ece9a..7622a3a 100644
@@ -1190,6 +1190,7 @@ static int ehci_init_transfer(EHCIPacket *p)
     while (bytes > 0) {
         if (cpage > 4) {
             fprintf(stderr, "cpage out of range (%d)\n", cpage);
+            qemu_sglist_destroy(&p->sgl);
             return -1;
         }
 
Signature · 1 line
1.8.3.1
#2 lore raw

[Qemu-devel] [PULL 2/2] usbredir: free vm_change_state_handler in usbredir destroy dispatch

In reply to Gerd Hoffmann

From: Li Qiang <[email protected]>

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.

Message-id: [email protected]

---
 hw/usb/redirect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/usb/redirect.c +4 -1
index 528081e..a657237 100644
@@ -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)
Signature · 1 line
1.8.3.1
#3 lore raw
In reply to Gerd Hoffmann
Quoted 23 lines · Gerd Hoffmann

Hi,

Here is the usb patch queue, fixing two memory leaks.

please pull,
Gerd

The following changes since commit 207faf24c58859f5240f66bf6decc33b87a1776e:

Merge remote-tracking branch 'pm215/tags/pull-target-arm-20161107' into staging (2016-11-07 14:02:15 +0000)

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-usb-20161109-1

for you to fetch changes up to f0bf4999eae156142a86290fda45de4094e3e8b4:

usbredir: free vm_change_state_handler in usbredir destroy dispatch (2016-11-08 15:01:23 +0100)

----------------------------------------------------------------
usb: two memory leak fixes.

Quoted 9 lines

----------------------------------------------------------------
Li Qiang (2):
usb: ehci: fix memory leak in ehci_init_transfer
usbredir: free vm_change_state_handler in usbredir destroy dispatch

 hw/usb/hcd-ehci.c | 1 +
 hw/usb/redirect.c | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Thanks, applied to my staging tree:
https://github.com/stefanha/qemu/commits/staging

Stefan