]> git.proxmox.com Git - mirror_qemu.git/commitdiff
usb-storage: fix possible memory leak and missing error message
authorGonglei <arei.gonglei@huawei.com>
Fri, 19 Sep 2014 06:48:23 +0000 (14:48 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 23 Sep 2014 09:41:45 +0000 (11:41 +0200)
When scsi_bus_legacy_add_drive() return NULL, meanwhile err will
be not NULL, which will casue memory leak and missing error message.

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-storage.c

index eb75f6adb96cdc26df009a6ee13420abe79ee069..55ef6848a77f3baf7c361bc2cbc24d3c8de698c4 100644 (file)
@@ -624,6 +624,8 @@ static int usb_msd_initfn_storage(USBDevice *dev)
                                          s->conf.bootindex, dev->serial,
                                          &err);
     if (!scsi_dev) {
+        error_report("%s", error_get_pretty(err));
+        error_free(err);
         return -1;
     }
     s->bus.qbus.allow_hotplug = 0;