The branch stable/14 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=1616f7d4b57bd463431ee2af7710b4f9d96db6ea
commit 1616f7d4b57bd463431ee2af7710b4f9d96db6ea Author: Pierre Pronchery <[email protected]> AuthorDate: 2024-08-05 07:46:01 +0000 Commit: Corvin Köhne <[email protected]> CommitDate: 2024-11-12 07:54:21 +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 (cherry picked from commit 1f3bfc60550cdd019f00bf6d274db762fda4ed2c) --- 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 6aeafe7f0ec1..95cd8b1aae31 100644 --- a/usr.sbin/bhyve/tpm_intf_crb.c +++ b/usr.sbin/bhyve/tpm_intf_crb.c @@ -349,8 +349,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;
