The 'nodes' is overwritten after the first usage and possibly leaked
if any code in the first set of parsing goes to error.
Found by Coverity.
Signed-off-by: John Ferlan <jferlan@redhat.com>
{
virNodeDeviceDefPtr def;
virNodeDevCapsDefPtr *next_cap;
- xmlNodePtr *nodes;
+ xmlNodePtr *nodes = NULL;
int n, m;
size_t i;
def->sysfs_path = virXPathString("string(./path[1])", ctxt);
/* Parse devnodes */
- nodes = NULL;
if ((n = virXPathNodeSet("./devnode", ctxt, &nodes)) < 0)
goto error;
ctxt);
/* Parse device capabilities */
- nodes = NULL;
+ VIR_FREE(nodes);
if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0)
goto error;
nodes[i],
create,
virt_type);
- if (!*next_cap) {
- VIR_FREE(nodes);
+ if (!*next_cap)
goto error;
- }
next_cap = &(*next_cap)->next;
}
error:
virNodeDeviceDefFree(def);
+ VIR_FREE(nodes);
return NULL;
}