[Qemu-devel] [PATCH v1 2/3] qcow2: fix the uninitialized bitmap_table variable

Dima Stepanov posted 3 patches 7 years, 8 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v1 2/3] qcow2: fix the uninitialized bitmap_table variable
Posted by Dima Stepanov 7 years, 8 months ago
The free_bitmap_clusters() routine is using the bitmap_table_load() call
to initialize the local bitmap_table variable. bitmap_table_load()
doesn't initialize variable to NULL in case of error. As a result a
following assert will be hit:
  assert(bitmap_table == NULL);

Remove this assert, since the next instruction is return from routine.

Signed-off-by: Dima Stepanov <dimastep@yandex-team.ru>
---
 block/qcow2-bitmap.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 60d5290..69485aa 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -254,7 +254,6 @@ static int free_bitmap_clusters(BlockDriverState *bs, Qcow2BitmapTable *tb)
 
     ret = bitmap_table_load(bs, tb, &bitmap_table);
     if (ret < 0) {
-        assert(bitmap_table == NULL);
         return ret;
     }
 
-- 
2.7.4


Re: [Qemu-devel] [PATCH v1 2/3] qcow2: fix the uninitialized bitmap_table variable
Posted by Philippe Mathieu-Daudé 7 years, 8 months ago
Hi Dima,

On 06/09/2018 04:52 AM, Dima Stepanov wrote:
> The free_bitmap_clusters() routine is using the bitmap_table_load() call
> to initialize the local bitmap_table variable. bitmap_table_load()
> doesn't initialize variable to NULL in case of error. As a result a
> following assert will be hit:
>   assert(bitmap_table == NULL);
> 
> Remove this assert, since the next instruction is return from routine.

Paolo suggested a different fix, see:

https://patchwork.kernel.org/patch/9860017/

> 
> Signed-off-by: Dima Stepanov <dimastep@yandex-team.ru>
> ---
>  block/qcow2-bitmap.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index 60d5290..69485aa 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -254,7 +254,6 @@ static int free_bitmap_clusters(BlockDriverState *bs, Qcow2BitmapTable *tb)
>  
>      ret = bitmap_table_load(bs, tb, &bitmap_table);
>      if (ret < 0) {
> -        assert(bitmap_table == NULL);
>          return ret;
>      }
>  
>