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