[libvirt] [PATCH] virDomainHostdevSubsysSCSIVHostDefParseXML: Don't leak @wwpn

Peter Krempa pkrempa at redhat.com
Fri Jan 20 15:11:15 UTC 2017


On Fri, Jan 20, 2017 at 15:53:18 +0100, Michal Privoznik wrote:

In subject. In fact actually 'protocol' was leaked.

> ==24748== 12 bytes in 2 blocks are definitely lost in loss record 25 of 84
> ==24748==    at 0x4C2BF80: malloc (vg_replace_malloc.c:296)
> ==24748==    by 0x1A1E1E78: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
> ==24748==    by 0x18D0495F: virXMLPropString (virxml.c:506)
> ==24748==    by 0x18D1FB3E: virDomainHostdevSubsysSCSIVHostDefParseXML (domain_conf.c:6280)
> ==24748==    by 0x18D20350: virDomainHostdevDefParseXMLSubsys (domain_conf.c:6450)
> ==24748==    by 0x18D34E7D: virDomainHostdevDefParseXML (domain_conf.c:13218)
> ==24748==    by 0x18D42598: virDomainDefParseXML (domain_conf.c:17745)
> ==24748==    by 0x18D440A9: virDomainDefParseNode (domain_conf.c:18236)
> ==24748==    by 0x18D43EFA: virDomainDefParse (domain_conf.c:18180)
> ==24748==    by 0x18D43FA0: virDomainDefParseFile (domain_conf.c:18206)
> ==24748==    by 0x44EDA1: testCompareDomXML2XMLFiles (testutils.c:1140)
> ==24748==    by 0x4365F8: testXML2XMLActive (qemuxml2xmltest.c:59)
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/conf/domain_conf.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 52aee2b02..55d2c25b2 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -6274,13 +6274,14 @@ static int
>  virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode,
>                                             virDomainHostdevDefPtr def)
>  {
> -    char *protocol = NULL;
> +    char *protocol = NULL, *wwpn = NULL;

Only one variable per line please.

>      virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
> +    int ret = -1;
>  
>      if (!(protocol = virXMLPropString(sourcenode, "protocol"))) {
>          virReportError(VIR_ERR_XML_ERROR, "%s",
>                         _("Missing scsi_host subsystem protocol"));
> -        return -1;
> +        return ret;

This is not necessary.

>      }
>  
>      if ((hostsrc->protocol =

ACK iff you fix the commit message and the variable declaration.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170120/db513551/attachment-0001.sig>


More information about the libvir-list mailing list