diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-04-06 14:12:42 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-04-19 10:31:05 +0200 |
commit | b7c8c35f0afb62efcacd18a64067fe164e3206b6 (patch) | |
tree | 111a5619cc5c9adf97ef43736331f1718b12fca8 /hw/scsi-bus.c | |
parent | e6f5d0be730a41bacb10edba19d1369ec2949486 (diff) | |
download | qemu-b7c8c35f0afb62efcacd18a64067fe164e3206b6.tar.gz qemu-b7c8c35f0afb62efcacd18a64067fe164e3206b6.tar.bz2 qemu-b7c8c35f0afb62efcacd18a64067fe164e3206b6.zip |
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>
Diffstat (limited to 'hw/scsi-bus.c')
-rw-r--r-- | hw/scsi-bus.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 8e76c5d32c..d847396c53 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -1430,15 +1430,18 @@ static char *scsibus_get_dev_path(DeviceState *dev) SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev); DeviceState *hba = dev->parent_bus->parent; char *id = NULL; + char *path; if (hba && hba->parent_bus && hba->parent_bus->info->get_dev_path) { id = hba->parent_bus->info->get_dev_path(hba); } 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 { - 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) |