qcow2: Fix return value of alloc_refcount_block

Submitted by Kevin Wolf on April 18, 2012, 2:35 p.m.

Details

Message ID 1334759720-6821-1-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf April 18, 2012, 2:35 p.m.
Someone forgot something in commit 29c1a730... Documenting the right
return value is not enough, you also need to actually return it in the
code.

This bug sometimes causes error return values even when everything has
succeeded: The new offset of the refcount block is truncated to 32 bits
and interpreted as signed. At least with small cluster sizes it's easy
to get a negative return value this way.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2-refcount.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Paolo Bonzini April 18, 2012, 2:36 p.m.
Il 18/04/2012 16:35, Kevin Wolf ha scritto:
> Someone forgot something in commit 29c1a730... Documenting the right
> return value is not enough, you also need to actually return it in the
> code.
> 
> This bug sometimes causes error return values even when everything has
> succeeded: The new offset of the refcount block is truncated to 32 bits
> and interpreted as signed. At least with small cluster sizes it's easy
> to get a negative return value this way.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/qcow2-refcount.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index f39928a..565bd54 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -400,7 +400,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
>          return ret;
>      }
>  
> -    return new_block;
> +    return 0;
>  
>  fail_table:
>      g_free(new_table);

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch hide | download patch | download mbox

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index f39928a..565bd54 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -400,7 +400,7 @@  static int alloc_refcount_block(BlockDriverState *bs,
         return ret;
     }
 
-    return new_block;
+    return 0;
 
 fail_table:
     g_free(new_table);