Blob Blame History Raw
From ecbceb91ea354cac6f1301aed88035e61ca291c0 Mon Sep 17 00:00:00 2001
Message-Id: <ecbceb91ea354cac6f1301aed88035e61ca291c0@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 15 Sep 2014 15:13:52 -0400
Subject: [PATCH] xen: Resolve Coverity NEGATIVE_RETURNS

https://bugzilla.redhat.com/show_bug.cgi?id=1141209

Coverity notes that if the call to virBitmapParse() returns a negative
value, then when we jump to the error label, the call to
virCapabilitiesClearHostNUMACellCPUTopology() will have issues
with the negative nb_cpus

Signed-off-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit 947593f6e628f724607d51dfc346af6dc3edf01f)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/xen/xend_internal.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 6d1fec7..5a99025 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -1112,7 +1112,8 @@ sexpr_to_xend_topology(const struct sexpr *root, virCapsPtr caps)
  parse_error:
     virReportError(VIR_ERR_XEN_CALL, "%s", _("topology syntax error"));
  error:
-    virCapabilitiesClearHostNUMACellCPUTopology(cpuInfo, nb_cpus);
+    if (nb_cpus > 0)
+        virCapabilitiesClearHostNUMACellCPUTopology(cpuInfo, nb_cpus);
     VIR_FREE(cpuInfo);
     return -1;
 }
-- 
2.1.0