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

Re: [libvirt] [PATCH] qemu: update qemuCgroupControllerActive signature



On 05/03/2011 11:02 PM, Laine Stump wrote:
> On 05/03/2011 04:22 PM, Eric Blake wrote:
>> Clang warned about a dead assignment.  In the process, I noticed
>> that we are only using the function for a bool value.  I audited
>> all other callers in qemu_{migration,cgroup,driver,hotplug), and
>> all were making the call in a bool context.
>>
>> +bool qemuCgroupControllerActive(struct qemud_driver *driver,
>> +                                int controller)
>>   {
>>       if (driver->cgroup == NULL)
>> -        return 0;
>> +        return false;
>>       if (!virCgroupMounted(driver->cgroup, controller))
>> -        return 0;
>> +        return false;
>>       if (driver->cgroupControllers&  (1<<  controller))

Undefined behavior if controller is out of range.

> 
> ACK.

I pushed with this squashed in:

diff --git i/src/qemu/qemu_cgroup.c w/src/qemu/qemu_cgroup.c
index ac1c016..6f075fb 100644
--- i/src/qemu/qemu_cgroup.c
+++ w/src/qemu/qemu_cgroup.c
@@ -50,6 +50,8 @@ bool qemuCgroupControllerActive(struct qemud_driver
*driver,
         return false;
     if (!virCgroupMounted(driver->cgroup, controller))
         return false;
+    if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
+        return false;
     if (driver->cgroupControllers & (1 << controller))
         return true;
     return false;


-- 
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]