bochs: Fix memory leak in bochs_open() error path

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Kevin Wolf 2014-04-09 11:19:04 +02:00
parent f516a5cc05
commit 28ec11bc88
1 changed files with 4 additions and 2 deletions

View File

@ -150,11 +150,13 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
s->extent_size = le32_to_cpu(bochs.extent);
if (s->extent_size == 0) {
error_setg(errp, "Extent size may not be zero");
return -EINVAL;
ret = -EINVAL;
goto fail;
} else if (s->extent_size > 0x800000) {
error_setg(errp, "Extent size %" PRIu32 " is too large",
s->extent_size);
return -EINVAL;
ret = -EINVAL;
goto fail;
}
if (s->catalog_size < bs->total_sectors / s->extent_size) {