From: Alex Jia <ajia(a)redhat.com>
Detected in valgrind run:
==9184== 1 bytes in 1 blocks are definitely lost in loss record 1 of 19
==9184== at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184== by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184== by 0x4CF97C9: xdr_remote_domain_get_security_label_ret
(remote_protocol.c:1696)
==9184== by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184== by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184== by 0x4CE3887: call (remote_driver.c:3933)
==9184== by 0x4CF71C6: remoteDomainGetSecurityLabel (remote_driver.c:1580)
==9184== by 0x4CCA480: virDomainGetSecurityLabel (libvirt.c:7340)
==9184== by 0x41993A: cmdDominfo (virsh.c:2414)
==9184== by 0x411E92: vshCommandRun (virsh.c:12730)
==9184== by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== 2 bytes in 1 blocks are definitely lost in loss record 2 of 19
==9184== at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184== by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184== by 0x4CF974F: xdr_remote_node_get_security_model_ret (remote_protocol.c:1713)
==9184== by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184== by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184== by 0x4CE3887: call (remote_driver.c:3933)
==9184== by 0x4CF6F96: remoteNodeGetSecurityModel (remote_driver.c:1648)
==9184== by 0x4CBF799: virNodeGetSecurityModel (libvirt.c:7382)
==9184== by 0x4197D7: cmdDominfo (virsh.c:2394)
==9184== by 0x411E92: vshCommandRun (virsh.c:12730)
==9184== by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== 8 bytes in 1 blocks are definitely lost in loss record 3 of 19
==9184== at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184== by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184== by 0x4CF9729: xdr_remote_node_get_security_model_ret (remote_protocol.c:1710)
==9184== by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184== by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184== by 0x4CE3887: call (remote_driver.c:3933)
==9184== by 0x4CF6F96: remoteNodeGetSecurityModel (remote_driver.c:1648)
==9184== by 0x4CBF799: virNodeGetSecurityModel (libvirt.c:7382)
==9184== by 0x4197D7: cmdDominfo (virsh.c:2394)
==9184== by 0x411E92: vshCommandRun (virsh.c:12730)
==9184== by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== LEAK SUMMARY:
==9184== definitely lost: 11 bytes in 3 blocks
* src/remote/remote_driver.c: Avoid leak on remoteDomainGetSecurityLabel
and remoteNodeGetSecurityModel.
---
src/remote/remote_driver.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 8dff6a8..5c0457e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1587,7 +1587,7 @@ remoteDomainGetSecurityLabel (virDomainPtr domain,
virSecurityLabelPtr seclabel)
if (strlen (ret.label.label_val) >= sizeof seclabel->label) {
remoteError(VIR_ERR_RPC, _("security label exceeds maximum: %zd"),
sizeof seclabel->label - 1);
- goto done;
+ goto cleanup;
}
strcpy (seclabel->label, ret.label.label_val);
seclabel->enforcing = ret.enforcing;
@@ -1595,6 +1595,9 @@ remoteDomainGetSecurityLabel (virDomainPtr domain,
virSecurityLabelPtr seclabel)
rv = 0;
+cleanup:
+ xdr_free((xdrproc_t) xdr_remote_domain_get_security_label_ret, (char *)&ret);
+
done:
remoteDriverUnlock(priv);
return rv;
@@ -1655,7 +1658,7 @@ remoteNodeGetSecurityModel (virConnectPtr conn, virSecurityModelPtr
secmodel)
if (strlen (ret.model.model_val) >= sizeof secmodel->model) {
remoteError(VIR_ERR_RPC, _("security model exceeds maximum: %zd"),
sizeof secmodel->model - 1);
- goto done;
+ goto cleanup;
}
strcpy (secmodel->model, ret.model.model_val);
}
@@ -1664,13 +1667,16 @@ remoteNodeGetSecurityModel (virConnectPtr conn,
virSecurityModelPtr secmodel)
if (strlen (ret.doi.doi_val) >= sizeof secmodel->doi) {
remoteError(VIR_ERR_RPC, _("security doi exceeds maximum: %zd"),
sizeof secmodel->doi - 1);
- goto done;
+ goto cleanup;
}
strcpy (secmodel->doi, ret.doi.doi_val);
}
rv = 0;
+cleanup:
+ xdr_free((xdrproc_t) xdr_remote_node_get_security_model_ret, (char *)&ret);
+
done:
remoteDriverUnlock(priv);
return rv;
--
1.7.1