qemu: reorder checks for safety

Detected by Coverity.  All existing callers happen to be in
range, so this isn't too serious.

* src/qemu/qemu_cgroup.c (qemuCgroupControllerActive): Check
bounds before dereference.
This commit is contained in:
Eric Blake 2011-06-06 13:07:11 -06:00
parent 208a675688
commit 4eb17d642e

View File

@ -48,10 +48,10 @@ bool qemuCgroupControllerActive(struct qemud_driver *driver,
{
if (driver->cgroup == NULL)
return false;
if (!virCgroupMounted(driver->cgroup, controller))
return false;
if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
return false;
if (!virCgroupMounted(driver->cgroup, controller))
return false;
if (driver->cgroupControllers & (1 << controller))
return true;
return false;