Skip to contentSkip to conversation

fix coverity bugs

PATCH In review Vladimir Sementsov-Ogievskiy 2 participants 5 messages Apr 27, 2018

lore
Share & tools
lore
#0 lore raw

cover fix coverity bugs

Hi all.

Here are two bug fixes, thanks to Peter for reporting.

Both are introduced in 2.12.

Vladimir Sementsov-Ogievskiy (2):
nbd/client: fix nbd_negotiate_simple_meta_context migration/block-dirty-bitmap: fix memory leak in
dirty_bitmap_load_bits

 migration/block-dirty-bitmap.c | 1 +
 nbd/client.c                   | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.11.1
#1 lore raw

PATCH 1/2 nbd/client: fix nbd_negotiate_simple_meta_context

Initialize received variable. Otherwise, is is possible for server to answer without any contexts, but we will set context_id to something random (received_id is not initialized too) and return 1, which is wrong.

To solve it, just initialize received to false. Initialize received_id too, just to make all possible checkers happy.

But was introduced in 78a33ab58782efdb206de14 "nbd: BLOCK_STATUS for standard get_block_status function: client part" with the whole function.

---
 nbd/client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
nbd/client.c +2 -2
index b9e175d1c2..7f35b5c323 100644
@@ -613,8 +613,8 @@ static int nbd_negotiate_simple_meta_context(QIOChannel *ioc,
 {
     int ret;
     NBDOptionReply reply;
-    uint32_t received_id;
-    bool received;
+    uint32_t received_id = 0;
+    bool received = false;
     uint32_t export_len = strlen(export);
     uint32_t context_len = strlen(context);
     uint32_t data_len = sizeof(export_len) + export_len +
Signature · 1 line
2.11.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] nbd/client: fix nbd_negotiate_simple_meta_context

Quoted 9 lines · Vladimir Sementsov-Ogievskiy

Initialize received variable. Otherwise, is is possible for server to answer without any contexts, but we will set context_id to something random (received_id is not initialized too) and return 1, which is wrong.

To solve it, just initialize received to false. Initialize received_id too, just to make all possible checkers happy.

But was introduced in 78a33ab58782efdb206de14 "nbd: BLOCK_STATUS for

s/But/Bug/

Quoted 7 lines

standard get_block_status function: client part" with the whole function.

---
 nbd/client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw

PATCH 2/2 migration/block-dirty-bitmap: fix memory leak in dirty_bitmap_load_bits

In reply to Vladimir Sementsov-Ogievskiy

Release buf on error path too.

Bug was introduced in b35ebdf076d697bc "migration: add postcopy migration of dirty bitmaps" with the whole function.

---
 migration/block-dirty-bitmap.c | 1 +
 1 file changed, 1 insertion(+)
migration/block-dirty-bitmap.c +1 -0
index dd04f102d8..8819aabe3a 100644
@@ -600,6 +600,7 @@ static int dirty_bitmap_load_bits(QEMUFile *f, DirtyBitmapLoadState *s)
         ret = qemu_get_buffer(f, buf, buf_size);
         if (ret != buf_size) {
             error_report("Failed to read bitmap bits");
+            g_free(buf);
             return -EIO;
         }
 
Signature · 1 line
2.11.1
Reviewed-by on the v1 series
#4 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 10 lines · Vladimir Sementsov-Ogievskiy

Hi all.

Here are two bug fixes, thanks to Peter for reporting.

Both are introduced in 2.12.

Vladimir Sementsov-Ogievskiy (2):
nbd/client: fix nbd_negotiate_simple_meta_context migration/block-dirty-bitmap: fix memory leak in
dirty_bitmap_load_bits

Adding both to my NBD queue

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