[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/6] bochs: Fix bdrv_open() error handling
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH 1/6] bochs: Fix bdrv_open() error handling |
Date: |
Thu, 24 Jan 2013 14:08:58 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 |
Am 24.01.2013 13:43, schrieb Markus Armbruster:
> Kevin Wolf <address@hidden> writes:
>
>> Return -errno instead of -1 on errors. While touching the
>> code, fix a memory leak.
>>
>> Signed-off-by: Kevin Wolf <address@hidden>
>> ---
>> block/bochs.c | 22 +++++++++++++++-------
>> 1 files changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/block/bochs.c b/block/bochs.c
>> index 3737583..a6eb33d 100644
>> --- a/block/bochs.c
>> +++ b/block/bochs.c
>> @@ -114,11 +114,13 @@ static int bochs_open(BlockDriverState *bs, int flags)
>> int i;
>> struct bochs_header bochs;
>> struct bochs_header_v1 header_v1;
>> + int ret;
>>
>> bs->read_only = 1; // no write support yet
>>
>> - if (bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)) != sizeof(bochs)) {
>> - goto fail;
>> + ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
>> + if (ret < 0) {
>> + return ret;
>> }
>>
>> if (strcmp(bochs.magic, HEADER_MAGIC) ||
> strcmp(bochs.type, REDOLOG_TYPE) ||
> strcmp(bochs.subtype, GROWING_TYPE) ||
> ((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
> (le32_to_cpu(bochs.version) != HEADER_V1))) {
>
> I'm afraid you need to set ret here. I wonder why the compiler didn't
> flag it.
>
> goto fail;
> }
This is against the block branch with Stefan's patches applied, so it's
actually 'return -EMEDIUMTYPE' instead of 'goto fail'.
Kevin
[Qemu-devel] [PATCH 5/6] dmg: Use g_free instead of free, Kevin Wolf, 2013/01/24
[Qemu-devel] [PATCH 6/6] parallels: Fix bdrv_open() error handling, Kevin Wolf, 2013/01/24
[Qemu-devel] [PATCH 4/6] dmg: Fix bdrv_open() error handling, Kevin Wolf, 2013/01/24