mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-12 22:51:29 +00:00
xen: Resolve resource leak with 'cpuset'
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.
This commit is contained in:
parent
c6248f0484
commit
8bc18eaac6
@ -373,6 +373,7 @@ int virBitmapParse(const char *str,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sa_assert(ret >= 0);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
parse_error:
|
parse_error:
|
||||||
|
@ -1113,7 +1113,6 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
{
|
{
|
||||||
const char *nodeToCpu;
|
const char *nodeToCpu;
|
||||||
const char *cur;
|
const char *cur;
|
||||||
virBitmapPtr cpuset = NULL;
|
|
||||||
int *cpuNums = NULL;
|
int *cpuNums = NULL;
|
||||||
int cell, cpu, nb_cpus;
|
int cell, cpu, nb_cpus;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -1131,6 +1130,7 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
|
|
||||||
cur = nodeToCpu;
|
cur = nodeToCpu;
|
||||||
while (*cur != 0) {
|
while (*cur != 0) {
|
||||||
|
virBitmapPtr cpuset = NULL;
|
||||||
/*
|
/*
|
||||||
* Find the next NUMA cell described in the xend output
|
* Find the next NUMA cell described in the xend output
|
||||||
*/
|
*/
|
||||||
@ -1163,28 +1163,22 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
if (used)
|
if (used)
|
||||||
cpuNums[n++] = cpu;
|
cpuNums[n++] = cpu;
|
||||||
}
|
}
|
||||||
|
virBitmapFree(cpuset);
|
||||||
|
|
||||||
if (virCapabilitiesAddHostNUMACell(caps,
|
if (virCapabilitiesAddHostNUMACell(caps, cell, nb_cpus, cpuNums) < 0)
|
||||||
cell,
|
|
||||||
nb_cpus,
|
|
||||||
cpuNums) < 0)
|
|
||||||
goto memory_error;
|
goto memory_error;
|
||||||
}
|
}
|
||||||
VIR_FREE(cpuNums);
|
VIR_FREE(cpuNums);
|
||||||
virBitmapFree(cpuset);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
parse_error:
|
parse_error:
|
||||||
virReportError(VIR_ERR_XEN_CALL, "%s", _("topology syntax error"));
|
virReportError(VIR_ERR_XEN_CALL, "%s", _("topology syntax error"));
|
||||||
error:
|
error:
|
||||||
VIR_FREE(cpuNums);
|
VIR_FREE(cpuNums);
|
||||||
virBitmapFree(cpuset);
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memory_error:
|
memory_error:
|
||||||
VIR_FREE(cpuNums);
|
VIR_FREE(cpuNums);
|
||||||
virBitmapFree(cpuset);
|
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user