migration: use g_free for ram load bitmap
PATCH 1/1 migration: use g_free for ram load bitmap
Buffers allocated with bitmap_new() should be freed with g_free().
Both reported by Coverity:
*** CID 1391300: API usage errors (ALLOC_FREE_MISMATCH) /migration/ram.c: 3517 in ram_dirty_bitmap_reload()
3511 * the last one to sync, we need to notify the main send thread.
3512 */
3513 ram_dirty_bitmap_reload_notify(s);
3514
3515 ret = 0;
3516 out:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1391300: API usage errors (
ALLOC_FREE_MISMATCH)
Calling "free" frees "le_bitmap" using "free" but it should have been freed using "g_free".
3517 free(le_bitmap);
3518 return ret;
3519 }
3520
3521 static int ram_resume_prepare(MigrationState *s, void *opaque)
3522 {
*** CID 1391292: API usage errors (ALLOC_FREE_MISMATCH) /migration/ram.c: 249 in ramblock_recv_bitmap_send()
243 * Mark as an end, in case the middle part is screwed up due to 244 * some "misterious" reason. 245 */
246 qemu_put_be64(file, RAMBLOCK_RECV_BITMAP_ENDING);
247 qemu_fflush(file);
248
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1391292: API usage errors (
ALLOC_FREE_MISMATCH)
Calling "free" frees "le_bitmap" using "free" but it should have been freed using "g_free".
249 free(le_bitmap);
250
251 if (qemu_file_get_error(file)) {
252 return qemu_file_get_error(file);
253 }
254
--- migration/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
migration/ram.c +2 -2
@@ -246,7 +246,7 @@ int64_t ramblock_recv_bitmap_send(QEMUFile *file,qemu_put_be64 (file,RAMBLOCK_RECV_BITMAP_ENDING );qemu_fflush (file); -free (le_bitmap); +g_free (le_bitmap);if (qemu_file_get_error (file)) {return qemu_file_get_error (file);
@@ -3514,7 +3514,7 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block) ret =0 ; out: -free (le_bitmap); +g_free (le_bitmap);return ret; }
Signature · 1 line
2.17.0
Quoted 59 lines · Peter Xu
Buffers allocated with
bitmap_new()should be freed withg_free().Both reported by Coverity:
*** CID 1391300: API usage errors (
ALLOC_FREE_MISMATCH) /migration/ram.c: 3517 inram_dirty_bitmap_reload()
3511 * the last one to sync, we need to notify the main send thread.
3512 */
3513ram_dirty_bitmap_reload_notify(s);
3514
3515 ret = 0;
3516 out:Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
CID 1391300: API usage errors (
ALLOC_FREE_MISMATCH) Calling "free" frees "le_bitmap" using "free" but it should
have been freed using "g_free".3517
free(le_bitmap);
3518 return ret;
3519 }
3520
3521 static intram_resume_prepare(MigrationState *s, void *opaque)
3522 {*** CID 1391292: API usage errors (
ALLOC_FREE_MISMATCH) /migration/ram.c: 249 inramblock_recv_bitmap_send()243 * Mark as an end, in case the middle part is screwed up due to 244 * some "misterious" reason. 245 */246
qemu_put_be64(file, RAMBLOCK_RECV_BITMAP_ENDING);
247qemu_fflush(file);
248Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
CID 1391292: API usage errors (
ALLOC_FREE_MISMATCH) Calling "free" frees "le_bitmap" using "free" but it should
have been freed using "g_free".249
free(le_bitmap);
250
251 if (qemu_file_get_error(file)) {
252 returnqemu_file_get_error(file);
253 }
254Signed-off-by Peter Xu <[email protected]>--- migration/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)migration/ram.c +1
-1@@ -246,7 +246,7 @@ int64_t ramblock_recv_bitmap_send(QEMUFile *file,qemu_put_be64 (file,RAMBLOCK_RECV_BITMAP_ENDING );qemu_fflush (file); -free (le_bitmap); +g_free (le_bitmap);if (qemu_file_get_error (file)) {return qemu_file_get_error (file);
migration/ram.c int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block) · line 3519
Quoted 7 lines
migration/ram.c +1
-1@@ -3514,7 +3514,7 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block) ret =0 ; out: -free (le_bitmap); +g_free (le_bitmap);return ret; }
Queued
Quoted 38 lines · Peter Xu
Buffers allocated with
bitmap_new()should be freed withg_free().Both reported by Coverity:
*** CID 1391300: API usage errors (
ALLOC_FREE_MISMATCH) /migration/ram.c: 3517 inram_dirty_bitmap_reload()
3511 * the last one to sync, we need to notify the main send thread.
3512 */
3513ram_dirty_bitmap_reload_notify(s);
3514
3515 ret = 0;
3516 out:Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1391300: API usage errors (
ALLOC_FREE_MISMATCH)
Calling "free" frees "le_bitmap" using "free" but it should have been freed using "g_free".3517
free(le_bitmap);
3518 return ret;
3519 }
3520
3521 static intram_resume_prepare(MigrationState *s, void *opaque)
3522 {*** CID 1391292: API usage errors (
ALLOC_FREE_MISMATCH) /migration/ram.c: 249 inramblock_recv_bitmap_send()243 * Mark as an end, in case the middle part is screwed up due to 244 * some "misterious" reason. 245 */246
qemu_put_be64(file, RAMBLOCK_RECV_BITMAP_ENDING);
247qemu_fflush(file);
248Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1391292: API usage errors (
ALLOC_FREE_MISMATCH)
Calling "free" frees "le_bitmap" using "free" but it should have been freed using "g_free".249
free(le_bitmap);
250
251 if (qemu_file_get_error(file)) {
252 returnqemu_file_get_error(file);
253 }
254
Quoted 5 lines
Signed-off-by Peter Xu <[email protected]>---
migration/ram.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
Jano