qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 02/11] qga-win: handle NULL values


From: Michael Roth
Subject: Re: [Qemu-devel] [PATCH v4 02/11] qga-win: handle NULL values
Date: Wed, 10 Oct 2018 18:08:40 -0500
User-agent: alot/0.7

Quoting Tomáš Golembiovský (2018-10-04 06:22:29)
> Handle returned NULLs properly to:
> - avoid crashes in serialization.
> - properly report errors to the caller
> 
> Signed-off-by: Tomáš Golembiovský <address@hidden>
> ---
>  qga/commands-win32.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 9c959122d9..49fc747298 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -735,6 +735,12 @@ static GuestFilesystemInfo *build_guest_fsinfo(char 
> *guid, Error **errp)
>      }
>      fs->type = g_strdup(fs_name);
>      fs->disk = build_guest_disk_info(guid, errp);
> +    if (fs->disk == NULL) {
> +        g_free(fs);
> +        fs = NULL;
> +        goto free;
> +    }
> +

The QAPI schema defines fs->disk to be a list. In the current upstream
code (where CONFIG_NTDDSCSI is unset) we always set fs->disk to NULL
and that just results in an empty list, which works and doesn't violate
the schema, so I don't understand why that's needed here.

>  free:
>      g_free(mnt_point);
>      return fs;
> @@ -755,7 +761,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error 
> **errp)
>      do {
>          GuestFilesystemInfo *info = build_guest_fsinfo(guid, errp);
>          if (info == NULL) {
> -            continue;
> +            goto out;
>          }

This fails the whole guest_get_fsinfo command for any case where we
can't retrieve the 'disk' list for a particular volume. I would consider
that a regression in functionality.

Can you confirm this is for fixing the current code? Or is it just
something you need for something later in this series? If the latter,
I suspect this is the wrong place to address it.

>          new = g_malloc(sizeof(*ret));
>          new->value = info;
> @@ -767,6 +773,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error 
> **errp)
>          error_setg_win32(errp, GetLastError(), "failed to find next volume");
>      }
> 
> +out:
>      FindVolumeClose(vol_h);
>      return ret;
>  }
> -- 
> 2.19.0
> 




reply via email to

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