[libvirt] [PATCH] qemu: avoid dereference of null pointer

Alex Jia ajia at redhat.com
Thu Aug 4 17:14:14 UTC 2011


On 08/05/2011 12:18 AM, Eric Blake wrote:
> On 08/04/2011 09:51 AM, Alex Jia wrote:
>> * src/qemu/qemu_driver.c: avoid dereference of null pointer.
>>
>> Signed-off-by: Alex Jia<ajia at redhat.com>
>> ---
>>   src/qemu/qemu_driver.c |   27 ++++++++++++++++++---------
>>   1 files changed, 18 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index ce19be7..28ffff7 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -5697,7 +5697,8 @@ static int 
>> qemuDomainSetBlkioParameters(virDomainPtr dom,
>>                       continue;
>>                   }
>>
>> -                persistentDef->blkio.weight = params[i].value.ui;
>> +                if (params[i].value.ul)
>> +                    persistentDef->blkio.weight = params[i].value.ui;
>
> Why check ul, but then use ui?  That seems broken.
Ah, correct me, this is a typing error.
>
>>
>>               if (flags&  VIR_DOMAIN_AFFECT_CONFIG) {
>> -                vmdef->cputune.quota = params[i].value.l;
>> +                if (params[i].value.ul)
>> +                    vmdef->cputune.quota = params[i].value.l;
>
> Why check ul, but then use l?
this is also a typing error.
>
> Also, how does checking for a non-zero union value prevent a null 
> dereference?
>
To be honest, I'm not sure this, however, it's okay for ccc-analyzer if 
I add these judgements,
of course, I'm probably making a mistake, if so, please correct me.

Thanks,
Alex




More information about the libvir-list mailing list