Skip to content

Commit

Permalink
usbredir: free vm_change_state_handler in usbredir destroy dispatch
Browse files Browse the repository at this point in the history
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@360.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 58216976.d0236b0a.77b99.bcd6@mx.google.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
Li Qiang authored and stefanhaRH committed Nov 10, 2016
1 parent 791f977 commit 07b026f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hw/usb/redirect.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 07b026f

Please sign in to comment.