qemu-block
[Top][All Lists]
Advanced

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

Re: [RFC PATCH 1/4] block/vdi: When writing new bmap entry fails, don't


From: Philippe Mathieu-Daudé
Subject: Re: [RFC PATCH 1/4] block/vdi: When writing new bmap entry fails, don't leak the buffer
Date: Tue, 9 Mar 2021 13:06:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

On 3/9/21 12:58 PM, David Edmondson wrote:
> On Tuesday, 2021-03-09 at 12:09:55 +01, Philippe Mathieu-Daudé wrote:
> 
>> On 3/9/21 11:21 AM, David Edmondson wrote:
>>> If a new bitmap entry is allocated, requiring the entire block to be
>>> written, avoiding leaking the buffer allocated for the block should
>>> the write fail.
>>>
>>> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
>>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> Thanks.
> 
>>> ---
>>>  block/vdi.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/block/vdi.c b/block/vdi.c
>>> index 5627e7d764..2a6dc26124 100644
>>> --- a/block/vdi.c
>>> +++ b/block/vdi.c
>>> @@ -690,6 +690,7 @@ nonallocating_write:
>>>  
>>>      logout("finished data write\n");
>>>      if (ret < 0) {
>>> +        g_free(block);
>>>          return ret;
>>>      }
>>
>> Alternative using g_autofree:
> 
> Newfangled witchy magic!
> 
> I'm happy to change it if you think it beneficial.

I then saw the next patch which keeps modifying the same
function, so this might not be a great improvement after
all.




reply via email to

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