[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] x86ModelHasFeature: avoid NULL-dereference for unmatched CPU "feature"



On 05/17/2010 06:08 AM, Jim Meyering wrote:
> Here's another fix for a potential NULL-deref.
> x86cpuidFind can return NULL, yet this caller
> would dereference that pointer (via x86cpuidMatchMasked)
> without first checking.
> 
>      for (i = 0; i < feature->ncpuid; i++) {
>          cpuid = feature->cpuid + i;
>          model_cpuid = x86cpuidFind(model->cpuid, model->ncpuid,
>                                     cpuid->function);
> -        if (!x86cpuidMatchMasked(model_cpuid, cpuid))
> +        if (!model_cpuid || !x86cpuidMatchMasked(model_cpuid, cpuid))

ACK.

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]