mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 23:55:23 +00:00
xenapi: Resolve Coverity REVERSE_INULL
Coverity complains that "net_set" is compared to NULL before calling
xen_network_set_free, but used rather liberally before that. While
I was looking at the code I also noted that if the virAsprintfQuiet
fails, then we leak our structures - so I added those too.
(cherry picked from commit 6da29e0faa
)
This commit is contained in:
parent
e4afc2a29d
commit
2cb4b820fd
@ -399,7 +399,10 @@ createVifNetwork(virConnectPtr conn, xen_vm vm, int device,
|
|||||||
xen_network_set *net_set = NULL;
|
xen_network_set *net_set = NULL;
|
||||||
xen_network_record *net_rec = NULL;
|
xen_network_record *net_rec = NULL;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
if (xen_network_get_all(session, &net_set)) {
|
if (!xen_network_get_all(session, &net_set)) {
|
||||||
|
xen_vm_record_opt_free(vm_opt);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
for (cnt = 0; cnt < net_set->size; cnt++) {
|
for (cnt = 0; cnt < net_set->size; cnt++) {
|
||||||
if (xen_network_get_record(session, &net_rec, net_set->contents[cnt])) {
|
if (xen_network_get_record(session, &net_rec, net_set->contents[cnt])) {
|
||||||
if (STREQ(net_rec->bridge, bridge)) {
|
if (STREQ(net_rec->bridge, bridge)) {
|
||||||
@ -409,7 +412,6 @@ createVifNetwork(virConnectPtr conn, xen_vm vm, int device,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (cnt < net_set->size && net_rec) {
|
if (cnt < net_set->size && net_rec) {
|
||||||
xen_network network = NULL;
|
xen_network network = NULL;
|
||||||
xen_network_get_by_uuid(session, &network, net_rec->uuid);
|
xen_network_get_by_uuid(session, &network, net_rec->uuid);
|
||||||
@ -425,8 +427,12 @@ createVifNetwork(virConnectPtr conn, xen_vm vm, int device,
|
|||||||
vif_record->other_config = xen_string_string_map_alloc(0);
|
vif_record->other_config = xen_string_string_map_alloc(0);
|
||||||
vif_record->runtime_properties = xen_string_string_map_alloc(0);
|
vif_record->runtime_properties = xen_string_string_map_alloc(0);
|
||||||
vif_record->qos_algorithm_params = xen_string_string_map_alloc(0);
|
vif_record->qos_algorithm_params = xen_string_string_map_alloc(0);
|
||||||
if (virAsprintfQuiet(&vif_record->device, "%d", device) < 0)
|
if (virAsprintfQuiet(&vif_record->device, "%d", device) < 0) {
|
||||||
|
xen_vif_record_free(vif_record);
|
||||||
|
xen_network_record_free(net_rec);
|
||||||
|
xen_network_set_free(net_set);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
xen_vif_create(session, &vif, vif_record);
|
xen_vif_create(session, &vif, vif_record);
|
||||||
if (!vif) {
|
if (!vif) {
|
||||||
xen_vif_free(vif);
|
xen_vif_free(vif);
|
||||||
@ -438,7 +444,7 @@ createVifNetwork(virConnectPtr conn, xen_vm vm, int device,
|
|||||||
xen_vif_record_free(vif_record);
|
xen_vif_record_free(vif_record);
|
||||||
xen_network_record_free(net_rec);
|
xen_network_record_free(net_rec);
|
||||||
}
|
}
|
||||||
if (net_set != NULL) xen_network_set_free(net_set);
|
xen_network_set_free(net_set);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user