From nobody Mon Aug 05 08:00:29 2024 X-Original-To: dev-commits-src-main@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 4WcplL1Mmxz5SnCL; Mon, 05 Aug 2024 08:00:30 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WcplL0ZTcz4mhK; Mon, 5 Aug 2024 08:00:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722844830; 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=GCQJps21LNS3m0BY0TlKE7scpJ30EnV9nC3qRHoDlFQ=; b=cgCAJpiYBVCqwHdpazjY5zXbouTUmDGxN/pcJw1aPLmbU1nVvUvm0jV6Jl7RL5eJvctwkj 6qAkYVQzsc+7tZlNDJZqY83T1h25j1FxpDx0ylL6JB+OaJNuC48RbzEBU16RUlJrjl4cf8 nbi7kazlr16HgML4s1iQRxor4FG6MGUR91WOrZIIK04K/NmPVsuaxCu2xqx6CEltFvcmHa v0F1jKWMXq6l9rIRKCe8kGGcbn+q8jbR8MGHjG4p9/2R9TpIgbDdC8DiF1rwSLqfr5wSSd 4HUOTdcaBfiiVPn+jK5QWyX2wFFOyKsBdqbENwuRBddLMtxfBYnnV8ctTBP2MQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722844830; a=rsa-sha256; cv=none; b=tytgsMUa2YgU0LkuZjTsWctch8jnNWlyoK7caDR9xSnnO704GiRkqp8ZGqM4BrdCFHwawR 39S/WkPzTaye4sWyUveIsTMoREYduXRa9wAXmIHbOJmmRePuRVD+Wzs4kmQpGC50eDmYRg md/HRkJ+b3l8+soOX8uqm2w7EI1wgQa6GnmUYzOOfBnVqsF+acY/FxYQq6enAtsddHKuAR p/ewiN+jq8OHHL0AKHkpPezStOIMkBQSBCOBWuzRkghGqXBHNMjzdtATnDxpjbAnyRc9w5 ZPbMXNmNefPmnt5X5r7FZ0DYOw023N5OBmJa0G2cXDMuirxoIHuGr3tk9slQEQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722844830; 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=GCQJps21LNS3m0BY0TlKE7scpJ30EnV9nC3qRHoDlFQ=; b=g0EML6jCyGnZvJ51n7WCPmc0GeQYZeB35Ltel5IdRmPUUvQmYI0JvqySeNULj5d2A8mtTD Km62PjlX+pRy5C+ldPFDmEobX+JE3bm8r3rKAgxJAwTqOS7wuGy3CgWv4bTUTc7HOo4j3N NgUA9vaW0AxTPlqiZUwI8M81ZtXMVwPLLzZ1NXfu2vfERU/LEQcNNS8lS5nZEvZ64vm1m1 Vkbs4fVA6UtKHki0rbOioPQEiAdq+2CZUQ6G9lrSn6rx8L6FyUpluUVnORE2aluA7wKCqp b49EfR7cAqNBoHqWDWkm00iQhaj8DrG97nsENcEWfTOiIzoDxNXpmCLVeGUbZA== 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 4WcplL05FHzFxr; Mon, 5 Aug 2024 08:00:30 +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 47580TlU057250; Mon, 5 Aug 2024 08:00:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47580TxN057247; Mon, 5 Aug 2024 08:00:29 GMT (envelope-from git) Date: Mon, 5 Aug 2024 08:00:29 GMT Message-Id: <202408050800.47580TxN057247@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Corvin =?utf-8?Q?K=C3=B6hne?= Subject: git: 1f3bfc60550c - main - bhyve: avoid a potential deadlock List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 1f3bfc60550cdd019f00bf6d274db762fda4ed2c Auto-Submitted: auto-generated The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=1f3bfc60550cdd019f00bf6d274db762fda4ed2c commit 1f3bfc60550cdd019f00bf6d274db762fda4ed2c Author: Pierre Pronchery AuthorDate: 2024-08-05 07:46:01 +0000 Commit: Corvin Köhne 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;