]> git.proxmox.com Git - mirror_qemu.git/commitdiff
migration: Check that postcopy fd's are not NULL
authorJuan Quintela <quintela@redhat.com>
Wed, 3 Nov 2021 19:24:27 +0000 (20:24 +0100)
committerJuan Quintela <quintela@redhat.com>
Sat, 6 Nov 2021 11:35:29 +0000 (12:35 +0100)
If postcopy has finished, it frees the array.
But vhost-user unregister it at cleanup time.

fixes: c4f7538
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
migration/postcopy-ram.c

index e721f69d0f8fab344f41cba259dd6dcfab7747ce..d18b5d05b2fb742b4fc3fe79575270d432fcaca8 100644 (file)
@@ -1457,6 +1457,10 @@ void postcopy_unregister_shared_ufd(struct PostCopyFD *pcfd)
     MigrationIncomingState *mis = migration_incoming_get_current();
     GArray *pcrfds = mis->postcopy_remote_fds;
 
+    if (!pcrfds) {
+        /* migration has already finished and freed the array */
+        return;
+    }
     for (i = 0; i < pcrfds->len; i++) {
         struct PostCopyFD *cur = &g_array_index(pcrfds, struct PostCopyFD, i);
         if (cur->fd == pcfd->fd) {