mirror of https://github.com/xqemu/xqemu.git
scsi: fix memory leak
scsibus_get_dev_path is leaking id if it is not NULL. Fix it. Reported-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
e6f5d0be73
commit
b7c8c35f0a
|
@ -1430,15 +1430,18 @@ static char *scsibus_get_dev_path(DeviceState *dev)
|
||||||
SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev);
|
SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev);
|
||||||
DeviceState *hba = dev->parent_bus->parent;
|
DeviceState *hba = dev->parent_bus->parent;
|
||||||
char *id = NULL;
|
char *id = NULL;
|
||||||
|
char *path;
|
||||||
|
|
||||||
if (hba && hba->parent_bus && hba->parent_bus->info->get_dev_path) {
|
if (hba && hba->parent_bus && hba->parent_bus->info->get_dev_path) {
|
||||||
id = hba->parent_bus->info->get_dev_path(hba);
|
id = hba->parent_bus->info->get_dev_path(hba);
|
||||||
}
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
return g_strdup_printf("%s/%d:%d:%d", id, d->channel, d->id, d->lun);
|
path = g_strdup_printf("%s/%d:%d:%d", id, d->channel, d->id, d->lun);
|
||||||
} else {
|
} else {
|
||||||
return g_strdup_printf("%d:%d:%d", d->channel, d->id, d->lun);
|
path = g_strdup_printf("%d:%d:%d", d->channel, d->id, d->lun);
|
||||||
}
|
}
|
||||||
|
g_free(id);
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *scsibus_get_fw_dev_path(DeviceState *dev)
|
static char *scsibus_get_fw_dev_path(DeviceState *dev)
|
||||||
|
|
Loading…
Reference in New Issue