From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2 4/7] KVM: Protect all of kvm_vm_ioctl_create_vcpu() with kvm->lock
Date: Mon, 21 Sep 2026 17:59:03 +0000 [thread overview]
Message-ID: <20260921175904.40FD91F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921174445.911676-5-seanjc@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] kvm: mixing goto-based error handling with guard() in kvm_vm_ioctl_create_vcpu
--
commit 01402bb146d901e6f480f96bad9c9a7b5314ecb9
Author: Sean Christopherson <seanjc@google.com>
KVM: Protect all of kvm_vm_ioctl_create_vcpu() with kvm->lock
This commit serializes vCPU creation by holding the kvm->lock for the
entirety of kvm_vm_ioctl_create_vcpu(). It removes the manual lock/unlock calls
that previously existed around parts of the creation process and replaces them
with a scoped guard.
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -4165,6 +4165,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, unsigned long id)
> struct kvm_vcpu *vcpu;
> struct page *page;
>
> + guard(mutex)(&kvm->lock);
> +
> /*
> * KVM tracks vCPU IDs as 'int', be kind to userspace and reject
[ ... ]
> @@ -4287,10 +4277,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, unsigned long id)
> vcpu_free:
> kmem_cache_free(kvm_vcpu_cache, vcpu);
> vcpu_decrement:
> - mutex_lock(&kvm->lock);
> kvm->created_vcpus--;
> __clear_bit(id, kvm->vcpu_ids);
> - mutex_unlock(&kvm->lock);
> return r;
> }
[Severity: Low]
Does kvm_vm_ioctl_create_vcpu() in virt/kvm/kvm_main.c mix goto-based error
handling with the new scope-based guard()?
The cleanup subsystem guidelines forbid mixing scope-based guard() with
legacy goto error handling in the same function, as it creates confusing
ownership semantics and risks future double-free or resource leak bugs
during maintenance.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921174445.911676-1-seanjc@google.com?part=4
next prev parent reply other threads:[~2026-09-21 17:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 17:44 [PATCH v2 0/7] KVM: Serialize vCPU creation and revert vcpu_ids tracking Sean Christopherson
2026-09-21 17:44 ` [PATCH v2 1/7] KVM: Reject attempts to lock all vCPUs if vCPU creation is in-progress Sean Christopherson
2026-09-21 17:44 ` [PATCH v2 2/7] KVM: arm64: vgic: Rely on vCPU creation check in "trylock all vCPUs" Sean Christopherson
2026-09-21 17:44 ` [PATCH v2 3/7] KVM: RISC-V: Use kvm_is_vcpu_creation_in_progress() instead of open-coded equivalent Sean Christopherson
2026-09-21 17:44 ` [PATCH v2 4/7] KVM: Protect all of kvm_vm_ioctl_create_vcpu() with kvm->lock Sean Christopherson
2026-09-21 17:59 ` sashiko-bot [this message]
2026-09-21 17:44 ` [PATCH v2 5/7] KVM: Move check for existing vCPU ID to the top of vCPU creation Sean Christopherson
2026-09-21 17:44 ` [PATCH v2 6/7] Revert "KVM: Check for duplicate vcpu_id as early as possible" Sean Christopherson
2026-09-21 17:44 ` [PATCH v2 7/7] KVM: WARN if vCPU creation is in-progress when locking all vCPUs Sean Christopherson
2026-09-22 8:06 ` [PATCH v2 0/7] KVM: Serialize vCPU creation and revert vcpu_ids tracking Jean-Christophe Guillain
2026-09-22 19:15 ` Naveen N Rao
2026-09-26 5:18 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260921175904.40FD91F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox