Skip to content

Commit

Permalink
bhyve: avoid a potential deadlock
Browse files Browse the repository at this point in the history
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
  • Loading branch information
khorben authored and ckoehne committed Aug 5, 2024
1 parent acb4cb3 commit 1f3bfc6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion usr.sbin/bhyve/tpm_intf_crb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1f3bfc6

Please sign in to comment.