From nobody Thu Jan 26 22:12:23 2023 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 4P2w1M405Sz3c8Yp; Thu, 26 Jan 2023 22:12:23 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P2w1M353Xz3x2w; Thu, 26 Jan 2023 22:12:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674771143; 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=T2oIiZGBMVqXqJXv/tXDbWkv/V3igDQtrBmO+vD+5X8=; b=I02ixMF6zf84sI6lyRXhBbJOf4BI7VoWMBr1jex+mSJ2q9Dx6vKUAARL7b6SsUVDHGQTbt 2rXN8OofJckwrCwb5KRMP6t7mhVjUavCI59PvFdQvX6qip5UvMmGwVodZLJZDhW0vaXLB/ MNicCGTJUUzj3gMmT67232Cw2mnycghCoDZW3IG/JA9ueKAgCjLp0ke4r1jmigIe00fS2v FrNzfjIrPPeKTVmeVAlCzwnZnEhWrb225eJLWTz4/0KbApd5lD7MfRZCQqFrCUXTlsEQCj WeFluNUgIODewlS9SixLNVbEf1PJfsZ4PVYLAjq2V8vkqtQu9eTgGVQPQg7yEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674771143; 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=T2oIiZGBMVqXqJXv/tXDbWkv/V3igDQtrBmO+vD+5X8=; b=TZ5+HT5sAh1QOFN+0ysmQiAZPzlovxgrga3ZZVBPtH8AuQj4grFakzullu/E+uuutm0BQL EGFR4QbPIdPQ3wnFB9fPsipT9akVu3KS2UuxpvXOM9ez0eUTrDrmueHvbQDLuUG8M7mnrT iG4hEDCrrPzZ2R7WEgTg0L3SM91Ia1ZnslQtYlb3ZkWUjNaLkeWE2yRll9Mas2ePXMqhdA 8spIotVfKxmRaIgEu8FDMkMEc1HH1yE2+8xg1bU65OO39ds4AsfcQn0/WMB+AD6J++1Ghs 2VwVIN46nkvMlooiEymsz8uvh3PR9fLV/dPRMQ5tI8qmMaoJcVVJs3OWMhzxIw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674771143; a=rsa-sha256; cv=none; b=gFraAIFkrpGkYHNIClSlvRmSKD16DUSkz4Fl77bfmNe4yGtWCAsZU8IQ52uhI00rxouZEp K7wREskj96cClmgulMr9r/+uG2hLNJYrxrtnusvJB2qnZ09nXspCl11mprqhzlIEyN3fTn ofq0wH1TmxMou4QCvw3K+bNlwTGkEN/C5RLnLGfOuXS7UUlq/i3ThYcRebUFwK6aiDCCy8 GBqe+rOU2O6NUookgGqWhBLcRVQEqbPjGIj+aCjvCjBJecgqOa/DDclPNhuzTQV30jbMQt snp2tjLT7HUrh0v76GngN7WZH+0D2OUTemt0On+xJmG9SdpMYgPAiEnReulE3Q== 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 4P2w1M1mXCzljm; Thu, 26 Jan 2023 22:12:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30QMCNJN022625; Thu, 26 Jan 2023 22:12:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QMCNvJ022624; Thu, 26 Jan 2023 22:12:23 GMT (envelope-from git) Date: Thu, 26 Jan 2023 22:12:23 GMT Message-Id: <202301262212.30QMCNvJ022624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: a982814ef8dd - stable/13 - vmm: Avoid infinite loop in vcpu_lock_all error case. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a982814ef8dd0c2fb8fd935341a3cd354791d31c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a982814ef8dd0c2fb8fd935341a3cd354791d31c commit a982814ef8dd0c2fb8fd935341a3cd354791d31c Author: John Baldwin AuthorDate: 2022-12-09 18:26:49 +0000 Commit: John Baldwin CommitDate: 2023-01-26 22:07:33 +0000 vmm: Avoid infinite loop in vcpu_lock_all error case. Reported by: Coverity (CIDs 1501060,1501071) Reviewed by: corvink, markj, emaste Differential Revision: https://reviews.freebsd.org/D37648 (cherry picked from commit d212d6ebb4ea3b3e9c3964c1a6d3f41817e437e1) --- sys/amd64/vmm/vmm_dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c index 94b462feef6a..2d8ff43a74dd 100644 --- a/sys/amd64/vmm/vmm_dev.c +++ b/sys/amd64/vmm/vmm_dev.c @@ -149,7 +149,7 @@ vcpu_lock_all(struct vmmdev_softc *sc) { struct vcpu *vcpu; int error; - uint16_t i, maxcpus; + uint16_t i, j, maxcpus; vm_slock_vcpus(sc->vm); maxcpus = vm_get_maxcpus(sc->vm); @@ -163,11 +163,11 @@ vcpu_lock_all(struct vmmdev_softc *sc) } if (error) { - while (--i >= 0) { - vcpu = vm_vcpu(sc->vm, i); + for (j = 0; j < i; j++) { + vcpu = vm_vcpu(sc->vm, j); if (vcpu == NULL) continue; - vcpu_unlock_one(sc, i, vcpu); + vcpu_unlock_one(sc, j, vcpu); } vm_unlock_vcpus(sc->vm); }