Commit f0bc7fe3 authored by Gonglei's avatar Gonglei Committed by Gerd Hoffmann

usb-storage: fix possible memory leak and missing error message

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: default avatarGonglei <arei.gonglei@huawei.com>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 31376776
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment