Set xbzrle buffers to NULL after freeing them to avoid double free errors
PATCH 1/2 Set xbzrle buffers to NULL after freeing them to avoid double free errors
Signed-off-by Orit Wasserman <[email protected]>
--- arch_init.c | 3 +++ 1 file changed, 3 insertions(+)
arch_init.c +3 -0
@@ -587,6 +587,9 @@ static void migration_end(void)g_free (XBZRLE .current_buf);g_free (XBZRLE .decoded_buf);XBZRLE .cache =NULL ; +XBZRLE .encoded_buf =NULL ; +XBZRLE .current_buf =NULL ; +XBZRLE .decoded_buf =NULL ; } }
Signature · 1 line
1.8.3.1
PATCH 2/2 Add check for cache size smaller than page size
Signed-off-by Orit Wasserman <[email protected]>
--- arch_init.c | 4 ++++ migration.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
arch_init.c +4 -0
@@ -176,6 +176,10 @@ static struct {int64_t xbzrle_cache_resize (int64_t new_size) { +if (new_size <TARGET_PAGE_SIZE ) { +return -1 ; + } +if (XBZRLE .cache !=NULL ) {return cache_resize (XBZRLE .cache, new_size /TARGET_PAGE_SIZE ) *TARGET_PAGE_SIZE ;
migration.c +9 -1
@@ -455,6 +455,7 @@ void qmp_migrate_cancel(Error **errp)void qmp_migrate_set_cache_size (int64_t value,Error **errp) {MigrationState *s =migrate_get_current (); +int64_t new_size;/* Check for truncation */ if (value != (size_t )value) {
@@ -463,8 +464,14 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp)return ; } - s->xbzrle_cache_size =xbzrle_cache_resize (value); + new_size =xbzrle_cache_resize (value); +if (new_size <0 ) { +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"cache size" , +"is smaller than page size" ); +return ; + } + + s->xbzrle_cache_size = new_size; }int64_t qmp_query_migrate_cache_size (Error **errp)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 2/2] Add check for cache size smaller than page size
Quoted 1 line · Orit Wasserman
Signed-off-by Orit Wasserman <[email protected]>
Reviewed-by Juan Quintela <[email protected]>
Quoted 1 line · Orit Wasserman
Signed-off-by Orit Wasserman <[email protected]>
Reviewed-by Juan Quintela <[email protected]>