qemu/tests-vhost-user-test-release-mutex-on-protocol-viol.patch

41 lines
1.3 KiB
Diff
Raw Normal View History

From b09ffbe7b85f891a8f5d425e5a98298a55c8400b Mon Sep 17 00:00:00 2001
From: xiaowanghe <xiaowanghe_yewu@cmss.chinamobile.com>
Date: Sun, 6 Aug 2023 23:48:47 -0700
Subject: [PATCH] tests: vhost-user-test: release mutex on protocol violation
cherry picked from commit 9260993e27cdbbd2e829d405cc63b1faefec6088
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>
Signed-off-by: Wanghe Xiao <xiaowanghe_yewu@cmss.chinamobile.com>
---
tests/qtest/vhost-user-test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index 3d6337fb5c..d07babc06d 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -328,7 +328,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
if (size != msg.size) {
g_test_message("Wrong message size received %d != %d",
size, msg.size);
- return;
+ goto out;
}
}
@@ -429,6 +429,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
break;
}
+out:
g_mutex_unlock(&s->data_mutex);
}
--
2.41.0.windows.1