KVM: fix cpuid E2BIG handling for extended request types
authorMark McLoughlin <markmc@redhat.com>
Tue, 12 May 2009 11:36:44 +0000 (12:36 +0100)
committerAvi Kivity <avi@redhat.com>
Thu, 10 Sep 2009 05:32:39 +0000 (08:32 +0300)
If we run out of cpuid entries for extended request types
we should return -E2BIG, just like we do for the standard
request types.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/x86.c

index a93ba37eb52c57debe0671e95907c35315116fd2..25a1c5739dfc9ee98c51f962dde14887848b3de4 100644 (file)
@@ -1506,6 +1506,10 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
        for (func = 0x80000001; func <= limit && nent < cpuid->nent; ++func)
                do_cpuid_ent(&cpuid_entries[nent], func, 0,
                             &nent, cpuid->nent);
+       r = -E2BIG;
+       if (nent >= cpuid->nent)
+               goto out_free;
+
        r = -EFAULT;
        if (copy_to_user(entries, cpuid_entries,
                         nent * sizeof(struct kvm_cpuid_entry2)))