git: 1f3bfc60550c - main - bhyve: avoid a potential deadlock
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 05 Aug 2024 08:00:29 UTC
The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=1f3bfc60550cdd019f00bf6d274db762fda4ed2c commit 1f3bfc60550cdd019f00bf6d274db762fda4ed2c Author: Pierre Pronchery <khorben@defora.org> AuthorDate: 2024-08-05 07:46:01 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2024-08-05 07:48:22 +0000 bhyve: avoid a potential deadlock This unlocks a mutex in an error path, that would otherwise remain locked and potentially cause a deadlock later on. Reported by: Coverity Scan CID: 1521334 Reviewed by: corvink, markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45401 --- usr.sbin/bhyve/tpm_intf_crb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/tpm_intf_crb.c b/usr.sbin/bhyve/tpm_intf_crb.c index af0214dd1760..0f9a8d1dd53b 100644 --- a/usr.sbin/bhyve/tpm_intf_crb.c +++ b/usr.sbin/bhyve/tpm_intf_crb.c @@ -348,8 +348,10 @@ tpm_crb_mem_handler(struct vcpu *vcpu __unused, const int dir, pthread_mutex_lock(&crb->mutex); tpm_crb_mmiocpy(&start, val, size); - if (!start.start || crb->regs.ctrl_start.start) + if (!start.start || crb->regs.ctrl_start.start) { + pthread_mutex_unlock(&crb->mutex); break; + } crb->regs.ctrl_start.start = true;