[libvirt] [PATCH 2/2] cpu_x86: Handle error in x86DataToCPU when calling x86DataAdd

John Ferlan posted 2 patches 6 years, 7 months ago
[libvirt] [PATCH 2/2] cpu_x86: Handle error in x86DataToCPU when calling x86DataAdd
Posted by John Ferlan 6 years, 7 months ago
Commit 9c9620af called x86DataAdd without checking for an error,
so add the error checking.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/cpu/cpu_x86.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 978a60c90a..55b55da784 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -822,7 +822,8 @@ x86DataToCPU(const virCPUx86Data *data,
         for (blocker = hvModel->blockers; *blocker; blocker++) {
             if ((feature = x86FeatureFind(map, *blocker)) &&
                 !x86DataIsSubset(&copy, &feature->data))
-                x86DataAdd(&modelData, &feature->data);
+                if (x86DataAdd(&modelData, &feature->data) < 0)
+                    goto error;
         }
     }
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list