]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tests: vhost-user-test: release mutex on protocol violation
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 27 Apr 2023 12:54:02 +0000 (14:54 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 28 Apr 2023 13:56:41 +0000 (15:56 +0200)
chr_read() is printing an error message and returning with s->data_mutex taken.
This can potentially cause a hang.  Reported by Coverity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tests/qtest/vhost-user-test.c

index bf9f7c4248ca21e5cf4e1311121e18f43b558d1f..e4f95b2858f038c958f8b98a6079e33650ee91e4 100644 (file)
@@ -351,7 +351,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
         if (size != msg.size) {
             qos_printf("%s: Wrong message size received %d != %d\n",
                        __func__, size, msg.size);
-            return;
+            goto out;
         }
     }
 
@@ -509,6 +509,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
         break;
     }
 
+out:
     g_mutex_unlock(&s->data_mutex);
 }