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

Jim Meyering jim at meyering.net
Mon May 17 14:51:05 UTC 2010


Eric Blake wrote:
> 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.

Thanks.  Pushed.




More information about the libvir-list mailing list