diff mbox

[for-2.3] hmp: fix crash in 'info block -n -v'

Message ID 1429274688-8115-1-git-send-email-berto@igalia.com
State New
Headers show

Commit Message

Alberto Garcia April 17, 2015, 12:44 p.m. UTC
The image field in BlockDeviceInfo should never be null, however
bdrv_block_device_info() is not filling it in.

This makes the 'info block -n -v' command crash QEMU.

The proper solution is probably to move the relevant code from
bdrv_query_info() to bdrv_block_device_info(), but since we're too
close to the release for that this simpler workaround solves the
crash.

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 hmp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eric Blake April 17, 2015, 12:56 p.m. UTC | #1
On 04/17/2015 06:44 AM, Alberto Garcia wrote:
> The image field in BlockDeviceInfo should never be null, however
> bdrv_block_device_info() is not filling it in.
> 
> This makes the 'info block -n -v' command crash QEMU.
> 
> The proper solution is probably to move the relevant code from
> bdrv_query_info() to bdrv_block_device_info(), but since we're too
> close to the release for that this simpler workaround solves the
> crash.
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
>  hmp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>


> 
> diff --git a/hmp.c b/hmp.c
> index f31ae27..f142d36 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -391,7 +391,8 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
>                          inserted->iops_size);
>      }
>  
> -    if (verbose) {
> +    /* TODO: inserted->image should never be null */
> +    if (verbose && inserted->image) {
>          monitor_printf(mon, "\nImages:\n");
>          image_info = inserted->image;
>          while (1) {
>
Peter Maydell April 17, 2015, 2:40 p.m. UTC | #2
On 17 April 2015 at 13:44, Alberto Garcia <berto@igalia.com> wrote:
> The image field in BlockDeviceInfo should never be null, however
> bdrv_block_device_info() is not filling it in.
>
> This makes the 'info block -n -v' command crash QEMU.
>
> The proper solution is probably to move the relevant code from
> bdrv_query_info() to bdrv_block_device_info(), but since we're too
> close to the release for that this simpler workaround solves the
> crash.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>

Applied, thanks.

-- PMM
diff mbox

Patch

diff --git a/hmp.c b/hmp.c
index f31ae27..f142d36 100644
--- a/hmp.c
+++ b/hmp.c
@@ -391,7 +391,8 @@  static void print_block_info(Monitor *mon, BlockInfo *info,
                         inserted->iops_size);
     }
 
-    if (verbose) {
+    /* TODO: inserted->image should never be null */
+    if (verbose && inserted->image) {
         monitor_printf(mon, "\nImages:\n");
         image_info = inserted->image;
         while (1) {