Make cpuset local to the while loop and free it once done with it each
time through the loop. Add a sa_assert() to virBitmapParse() to keep Coverity
from believing there could be a negative return and possible resource leak.
}
}
+ sa_assert(ret >= 0);
return ret;
parse_error:
{
const char *nodeToCpu;
const char *cur;
- virBitmapPtr cpuset = NULL;
int *cpuNums = NULL;
int cell, cpu, nb_cpus;
int n = 0;
cur = nodeToCpu;
while (*cur != 0) {
+ virBitmapPtr cpuset = NULL;
/*
* Find the next NUMA cell described in the xend output
*/
if (used)
cpuNums[n++] = cpu;
}
+ virBitmapFree(cpuset);
- if (virCapabilitiesAddHostNUMACell(caps,
- cell,
- nb_cpus,
- cpuNums) < 0)
+ if (virCapabilitiesAddHostNUMACell(caps, cell, nb_cpus, cpuNums) < 0)
goto memory_error;
}
VIR_FREE(cpuNums);
- virBitmapFree(cpuset);
return 0;
parse_error:
virReportError(VIR_ERR_XEN_CALL, "%s", _("topology syntax error"));
error:
VIR_FREE(cpuNums);
- virBitmapFree(cpuset);
-
return -1;
memory_error:
VIR_FREE(cpuNums);
- virBitmapFree(cpuset);
virReportOOMError();
return -1;
}