]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: selftests: Allocate vcpus with correct size
authorZenghui Yu <zenghui.yu@linux.dev>
Wed, 8 Oct 2025 15:45:20 +0000 (23:45 +0800)
committerMarc Zyngier <maz@kernel.org>
Mon, 13 Oct 2025 13:27:55 +0000 (14:27 +0100)
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.

Signed-off-by: Zenghui Yu <zenghui.yu@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c

index 87922a89b1345631e669eb790a3a2947977431f8..b134a304f0a6c85464814458e1100378c13efbb3 100644 (file)
@@ -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);