Skip to content

Commit

Permalink
blockdev: Plug memory leak in drive_init() error paths
Browse files Browse the repository at this point in the history
Should have spotted this when doing commit 319ae52.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
Markus Armbruster authored and kevmw committed Feb 10, 2011
1 parent 2753d4a commit a9ae2bf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions blockdev.c
Original file line number Diff line number Diff line change
@@ -526,7 +526,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {
error_report("readonly not supported by this bus type");
return NULL;
goto err;
}
}

@@ -536,12 +536,19 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
if (ret < 0) {
error_report("could not open disk image %s: %s",
file, strerror(-ret));
return NULL;
goto err;
}

if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
return dinfo;

err:
bdrv_delete(dinfo->bdrv);
qemu_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next);
qemu_free(dinfo);
return NULL;
}

void do_commit(Monitor *mon, const QDict *qdict)

0 comments on commit a9ae2bf

Please sign in to comment.