[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3] exec: set map length to zero when returning NULL
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v3] exec: set map length to zero when returning NULL |
Date: |
Tue, 26 May 2020 10:01:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 5/26/20 9:50 AM, P J P wrote:
> From: Prasad J Pandit <address@hidden>
>
> When mapping physical memory into host's virtual address space,
> 'address_space_map' may return NULL if BounceBuffer is in_use.
> Set and return '*plen = 0' to avoid later NULL pointer dereference.
>
> Reported-by: Alexander Bulekov <address@hidden>
> Fixes: https://bugs.launchpad.net/qemu/+bug/1878259
> Signed-off-by: Prasad J Pandit <address@hidden>
> ---
> exec.c | 1 +
> 1 file changed, 1 insertion(+)
>
> Update v3: set *plen = 0;
> -> https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg06249.html
>
> diff --git a/exec.c b/exec.c
> index 5162f0d12f..4eea84bf66 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -3538,6 +3538,7 @@ void *address_space_map(AddressSpace *as,
>
> if (!memory_access_is_direct(mr, is_write)) {
> if (atomic_xchg(&bounce.in_use, true)) {
> + *plen = 0;
> return NULL;
> }
> /* Avoid unbounded allocations */
>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>