From nobody Tue Nov 12 07:55:40 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xndy5204Vz5bf7v; Tue, 12 Nov 2024 07:55:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xndy45Wvfz4dlm; Tue, 12 Nov 2024 07:55:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731398140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Uaq2FcRuknG89hI8l9lM6Ww2Ll0kRkV/rAZ9ugh//Os=; b=G6zGCb1nFJDHd6Txe3nuTJc98KGVCihap+IMXfI6fpeFMaTXLQ6r2qcZa8M7RpwfmnwCqu 9pxnCLQcQAieZnLFUkZS6oDpc6S8MLex/m0SJxRg5ZNG0vgA0OjBtSIMw5oJIOr/XjLEj+ TMsGHSxRd7ibcedV+MKzcEr83OD+CNQwosrhTRExE9K2i9VTvU9l/HtT4/qBmN8VOrIQwp B9HNNyjJhuWcXKpg7iC+/z+CL1ZwqF4HA5meWHgK1XQ9XQdZo52KiZngbaRS5Q5HcheFVG kii3upt3nl0MlDE1669wfQn5vy9tJhXgygAGpH8bmadWWHLWGCO8lj9w8gzFdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731398140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Uaq2FcRuknG89hI8l9lM6Ww2Ll0kRkV/rAZ9ugh//Os=; b=oHE24ahZmCJzB5W0hYRDx+/gd6sGcz11S9pyVJPrN8a6IOl+A/t6UJfOOwr8cclT+y2JPj nr8KjLplXZZgYjD0kbG5bM0S5pLnFeMuF9qBPGVk0ZuZZ0ZDw/jZAW51cq1SR2v9Tvhx+O Rx0Tjr6Xvj3BzUHu8LYTFc4NixoMk/xF7xLg/mTNsE72HFGGd4Btdc3eEJpFcBwKKheJ9N TBPyJbNZyUqp9QwyRcuu/rrsTNneEmOKmQk+mdx5AXoRht7BA8juUvM2NqI3aVPRVbusob GhuOthHuilep1PVW1PloNSBBAljHRAeqBN76xbJe/XE5FaFzMwBvbbcHL+lfjw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731398140; a=rsa-sha256; cv=none; b=NbVLzOwvWxlxxxSb/8brgMK7m7AKsvchgI+fKELoPA2nurdspWAR/rf/1nEZGwfAg3fc7V EgzcGgdRNnuGNY1r1V1vs5G+tEY8AtnlpSDUEdslo/bBeX+hOYvREEg+NTzK+eVWKYB3SM XpnZ+pqKwDIrsmRz1rA33o7TvNVbNmHv0R5RyTEkUJxTbOBHyxKFZ722geiIDBrzqZmEZT hTs0gv2pyeT6GE812uB9X5yFQhYwdXJ7VNcpv5KXpHLKx7y930kYjFRrpPUAh799QDkL9X 2YA15ePIzgFJgw7pcSBM1j8gBYsXyxxoQMdn7uMq8vd4IwpA+vO/dYIp5EB8eg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xndy457p1z127K; Tue, 12 Nov 2024 07:55:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AC7teJu076964; Tue, 12 Nov 2024 07:55:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AC7teAG076961; Tue, 12 Nov 2024 07:55:40 GMT (envelope-from git) Date: Tue, 12 Nov 2024 07:55:40 GMT Message-Id: <202411120755.4AC7teAG076961@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Corvin =?utf-8?Q?K=C3=B6hne?= Subject: git: 1616f7d4b57b - stable/14 - bhyve: avoid a potential deadlock List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 1616f7d4b57bd463431ee2af7710b4f9d96db6ea Auto-Submitted: auto-generated The branch stable/14 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=1616f7d4b57bd463431ee2af7710b4f9d96db6ea commit 1616f7d4b57bd463431ee2af7710b4f9d96db6ea Author: Pierre Pronchery AuthorDate: 2024-08-05 07:46:01 +0000 Commit: Corvin Köhne 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;