[Qemu-devel] [PATCH] qcow2-bitmap: fix bitmap_free

Vladimir Sementsov-Ogievskiy posted 1 patch 6 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170714123341.373857-1-vsementsov@virtuozzo.com
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
block/qcow2-bitmap.c | 4 ++++
1 file changed, 4 insertions(+)
[Qemu-devel] [PATCH] qcow2-bitmap: fix bitmap_free
Posted by Vladimir Sementsov-Ogievskiy 6 years, 9 months ago
Fix possible crash on error path in
qcow2_remove_persistent_dirty_bitmap. Although bitmap_free was added in
88ddffae8fc the bug was introduced later in commit 469c71edc72 (when
qcow2_remove_persistent_dirty_bitmap was added).

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/qcow2-bitmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 3e8735a20d..e8d3bdbd6e 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -487,6 +487,10 @@ static inline void bitmap_directory_to_be(uint8_t *dir, size_t size)
 
 static void bitmap_free(Qcow2Bitmap *bm)
 {
+    if (bm == NULL) {
+        return;
+    }
+
     g_free(bm->name);
     g_free(bm);
 }
-- 
2.11.1


Re: [Qemu-devel] [PATCH] qcow2-bitmap: fix bitmap_free
Posted by Max Reitz 6 years, 9 months ago
On 2017-07-14 14:33, Vladimir Sementsov-Ogievskiy wrote:
> Fix possible crash on error path in
> qcow2_remove_persistent_dirty_bitmap. Although bitmap_free was added in
> 88ddffae8fc the bug was introduced later in commit 469c71edc72 (when
> qcow2_remove_persistent_dirty_bitmap was added).
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  block/qcow2-bitmap.c | 4 ++++
>  1 file changed, 4 insertions(+)

Thanks, applied to my block branch:

https://github.com/XanClic/qemu/commits/block

Max

Re: [Qemu-devel] [PATCH] qcow2-bitmap: fix bitmap_free
Posted by Philippe Mathieu-Daudé 6 years, 8 months ago
Maybe worth adding "Coverity: CID 1377700"

On 07/14/2017 01:00 PM, Max Reitz wrote:
> On 2017-07-14 14:33, Vladimir Sementsov-Ogievskiy wrote:
>> Fix possible crash on error path in
>> qcow2_remove_persistent_dirty_bitmap. Although bitmap_free was added in
>> 88ddffae8fc the bug was introduced later in commit 469c71edc72 (when
>> qcow2_remove_persistent_dirty_bitmap was added).
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>   block/qcow2-bitmap.c | 4 ++++
>>   1 file changed, 4 insertions(+)
> 
> Thanks, applied to my block branch:
> 
> https://github.com/XanClic/qemu/commits/block
> 
> Max
> 

Re: [Qemu-devel] [PATCH] qcow2-bitmap: fix bitmap_free
Posted by Eric Blake 6 years, 8 months ago
On 07/25/2017 10:02 AM, Philippe Mathieu-Daudé wrote:
> Maybe worth adding "Coverity: CID 1377700"

At this point, the PULL request is already posted, so it may be too
late.  But it's not the end of the world if we miss the extra comment.

> 
> On 07/14/2017 01:00 PM, Max Reitz wrote:
>> On 2017-07-14 14:33, Vladimir Sementsov-Ogievskiy wrote:
>>> Fix possible crash on error path in
>>> qcow2_remove_persistent_dirty_bitmap. Although bitmap_free was added in
>>> 88ddffae8fc the bug was introduced later in commit 469c71edc72 (when
>>> qcow2_remove_persistent_dirty_bitmap was added).
>>>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>> Reviewed-by: Eric Blake <eblake@redhat.com>
>>> ---
>>>   block/qcow2-bitmap.c | 4 ++++
>>>   1 file changed, 4 insertions(+)
>>
>> Thanks, applied to my block branch:
>>
>> https://github.com/XanClic/qemu/commits/block
>>
>> Max
>>
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org