diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 52aee2b020c12fd016fc14c1f4d7d2594e170817..b9092bddeb3b364a7ca2fd4567bce36aca82ddfd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6275,12 +6275,14 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode, virDomainHostdevDefPtr def) { char *protocol = NULL; + char *wwpn = NULL; 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; } if ((hostsrc->protocol = @@ -6293,17 +6295,19 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode, switch ((virDomainHostdevSubsysSCSIHostProtocolType) hostsrc->protocol) { case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST: - if (!(hostsrc->wwpn = virXMLPropString(sourcenode, "wwpn"))) { + if (!(wwpn = virXMLPropString(sourcenode, "wwpn"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vhost-scsi hostdev source wwpn")); goto cleanup; } - if (!STRPREFIX(hostsrc->wwpn, "naa.") || - !virValidateWWN(hostsrc->wwpn + 4)) { + if (!STRPREFIX(wwpn, "naa.") || + !virValidateWWN(wwpn + 4)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed 'wwpn' value")); goto cleanup; } + hostsrc->wwpn = wwpn; + wwpn = NULL; break; case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE: case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST: @@ -6314,12 +6318,11 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode, break; } - return 0; - + ret = 0; cleanup: - VIR_FREE(hostsrc->wwpn); + VIR_FREE(wwpn); VIR_FREE(protocol); - return -1; + return ret; }