a41c76
From 8a18e258633c347eb421904c63c2265ed59d61b5 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <8a18e258633c347eb421904c63c2265ed59d61b5@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:33 +0200
a41c76
Subject: [PATCH] cpu_x86: Don't check return value of x86ModelCopy
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Thanks to glib allocation functions which abort on OOM the function
a41c76
cannot ever return NULL.
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 70f3041d39802e53a19901bee040ff33850cd5e0)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <3db9e891cf44e608a45504b120a5c276ead3ea8d.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 14 ++++----------
a41c76
 1 file changed, 4 insertions(+), 10 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index b87e3753da..45a073c1d0 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -1287,9 +1287,6 @@ x86ModelFromCPU(const virCPUDef *cpu,
a41c76
         model = g_new0(virCPUx86Model, 1);
a41c76
     }
a41c76
 
a41c76
-    if (!model)
a41c76
-        return NULL;
a41c76
-
a41c76
     for (i = 0; i < cpu->nfeatures; i++) {
a41c76
         virCPUx86FeaturePtr feature;
a41c76
         virCPUFeaturePolicy fpol;
a41c76
@@ -1869,9 +1866,7 @@ x86Compute(virCPUDefPtr host,
a41c76
         return VIR_CPU_COMPARE_INCOMPATIBLE;
a41c76
     }
a41c76
 
a41c76
-    if (!(diff = x86ModelCopy(host_model)))
a41c76
-        return VIR_CPU_COMPARE_ERROR;
a41c76
-
a41c76
+    diff = x86ModelCopy(host_model);
a41c76
     x86DataSubtract(&diff->data, &cpu_optional->data);
a41c76
     x86DataSubtract(&diff->data, &cpu_require->data);
a41c76
     x86DataSubtract(&diff->data, &cpu_disable->data);
a41c76
@@ -1892,8 +1887,7 @@ x86Compute(virCPUDefPtr host,
a41c76
     }
a41c76
 
a41c76
     if (guest) {
a41c76
-        if (!(guest_model = x86ModelCopy(host_model)))
a41c76
-            return VIR_CPU_COMPARE_ERROR;
a41c76
+        guest_model = x86ModelCopy(host_model);
a41c76
 
a41c76
         if (cpu->vendor && host_model->vendor &&
a41c76
             virCPUx86DataAddItem(&guest_model->data,
a41c76
@@ -3131,8 +3125,8 @@ virCPUx86ExpandFeatures(virCPUDefPtr cpu)
a41c76
         return -1;
a41c76
     }
a41c76
 
a41c76
-    if (!(model = x86ModelCopy(model)) ||
a41c76
-        x86DataToCPUFeatures(expanded, host ? -1 : VIR_CPU_FEATURE_REQUIRE,
a41c76
+    model = x86ModelCopy(model);
a41c76
+    if (x86DataToCPUFeatures(expanded, host ? -1 : VIR_CPU_FEATURE_REQUIRE,
a41c76
                              &model->data, map) < 0)
a41c76
         return -1;
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76