diff mbox series

[v1,2/3] qcow2: fix the uninitialized bitmap_table variable

Message ID 1528530764-21376-3-git-send-email-dimastep@yandex-team.ru
State New
Headers show
Series misc fixes found by static analyzer | expand

Commit Message

Dima Stepanov June 9, 2018, 7:52 a.m. UTC
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(-)

Comments

Philippe Mathieu-Daudé June 9, 2018, 2:40 p.m. UTC | #1
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;
>      }
>  
>
diff mbox series

Patch

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;
     }