[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH for 2.10 08/35] qcow2: fix null pointer derefere
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [PATCH for 2.10 08/35] qcow2: fix null pointer dereference |
Date: |
Mon, 24 Jul 2017 13:52:23 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 07/24/2017 01:27 PM, Philippe Mathieu-Daudé wrote:
> It seems this assert() was somehow misplaced.
>
> block/qcow2-refcount.c:2193:42: warning: Array access (from variable
> 'on_disk_reftable') results in a null pointer dereference
> on_disk_reftable[refblock_index] = refblock_offset;
> ~~~~~~~~~~~~~~~~ ^
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> block/qcow2-refcount.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Eric Blake <address@hidden>
>
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index c9b0dcb4f3..168fc32e7b 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -2189,6 +2189,8 @@ write_refblocks:
> * this will leak that range, but we can easily fix that by
> running
> * a leak-fixing check after this rebuild operation */
> reftable_offset = -1;
> + } else {
> + assert(on_disk_reftable);
> }
> on_disk_reftable[refblock_index] = refblock_offset;
>
> @@ -2258,8 +2260,6 @@ write_refblocks:
> goto write_refblocks;
> }
>
> - assert(on_disk_reftable);
> -
> for (refblock_index = 0; refblock_index < reftable_size;
> refblock_index++) {
> cpu_to_be64s(&on_disk_reftable[refblock_index]);
> }
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature