qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 4/7] Make error handling more consistent in img_


From: Kevin Wolf
Subject: [Qemu-devel] Re: [PATCH 4/7] Make error handling more consistent in img_create() and img_resize()
Date: Mon, 06 Dec 2010 16:57:37 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Fedora/3.0.10-1.fc12 Thunderbird/3.0.10

Am 06.12.2010 16:45, schrieb address@hidden:
> From: Jes Sorensen <address@hidden>
> 
> Signed-off-by: Jes Sorensen <address@hidden>
> ---
>  qemu-img.c |   14 +++++++++-----
>  1 files changed, 9 insertions(+), 5 deletions(-)

> @@ -1432,7 +1434,7 @@ static int img_resize(int argc, char **argv)
>      int c, ret, relative;
>      const char *filename, *fmt, *size;
>      int64_t n, total_size;
> -    BlockDriverState *bs;
> +    BlockDriverState *bs = NULL;
>      QEMUOptionParameter *param;
>      QEMUOptionParameter resize_options[] = {
>          {
> @@ -1483,14 +1485,16 @@ static int img_resize(int argc, char **argv)
>      param = parse_option_parameters("", resize_options, NULL);
>      if (set_option_parameter(param, BLOCK_OPT_SIZE, size)) {
>          /* Error message already printed when size parsing fails */
> -        exit(1);
> +        ret = -1;
> +        goto out;
>      }
>      n = get_option_parameter(param, BLOCK_OPT_SIZE)->value.n;
>      free_option_parameters(param);
>  
>      bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR);
>      if (!bs) {
> -        return 1;
> +        ret = -1;
> +        goto out;
>      }
>  
>      if (relative) {

bdrv_delete doesn't check for NULL, so this still isn't enough. Try
something like "qemu-img resize -f vmdx foo +0" and you'll get a segfault.

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]