Skip to contentSkip to conversation

KVM: arm64: selftests: Allocate vcpus with correct size

PATCH Applied Zenghui Yu 2 participants 2 messages Oct 8, 2025 – Oct 13, 2025

Subsystems (3)
lore
Share & tools
lore

Zenghui Yu

author
#0 lore raw

PATCH 1/1 KVM: arm64: selftests: Allocate vcpus with correct size

vcpus array contains pointers to struct kvm_vcpu {}. It is way overkill to allocate the array with (nr_cpus * sizeof(struct kvm_vcpu)). Fix the allocation by using the correct size.

---
 tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c +1 -1
index 87922a89b134..b134a304f0a6 100644
@@ -331,7 +331,7 @@ static void setup_vm(void)
 {
 	int i;
 
-	vcpus = malloc(test_data.nr_cpus * sizeof(struct kvm_vcpu));
+	vcpus = malloc(test_data.nr_cpus * sizeof(struct kvm_vcpu *));
 	TEST_ASSERT(vcpus, "Failed to allocate vCPU array");
 
 	vm = vm_create_with_vcpus(test_data.nr_cpus, guest_code, vcpus);
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Zenghui Yu

vcpus array contains pointers to struct kvm_vcpu {}. It is way overkill to allocate the array with (nr_cpus * sizeof(struct kvm_vcpu)). Fix the allocation by using the correct size.

Applied to fixes, thanks!

[1/1] KVM: arm64: selftests: Allocate vcpus with correct size

      commit: 2192d348c0aa0cc2e7249dc3709f21bfe0a0170c

Cheers,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.