[libvirt] [PATCH 1/5] qemu: Check virGetLastError return value for migration finish failure

John Ferlan jferlan at redhat.com
Fri Sep 4 14:30:58 UTC 2015


Commit id '2e7cea243' added a check for an error from Finish instead
of 'unexpected error'; however, if for some reason there wasn't an
error, then virGetLastError could return NULL resulting in the
NULL pointer deref to err->domain.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/libvirt-domain.c      | 3 ++-
 src/qemu/qemu_migration.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index cbf08fc..964a4d7 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -3195,7 +3195,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
                 orig_err->domain == VIR_FROM_QEMU &&
                 orig_err->code == VIR_ERR_OPERATION_FAILED) {
                 virErrorPtr err = virGetLastError();
-                if (err->domain == VIR_FROM_QEMU &&
+                if (err &&
+                    err->domain == VIR_FROM_QEMU &&
                     err->code != VIR_ERR_MIGRATE_FINISH_OK) {
                     virFreeError(orig_err);
                     orig_err = NULL;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index ff89ab5..d50d367 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5023,7 +5023,8 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
                 orig_err->domain == VIR_FROM_QEMU &&
                 orig_err->code == VIR_ERR_OPERATION_FAILED) {
                 virErrorPtr err = virGetLastError();
-                if (err->domain == VIR_FROM_QEMU &&
+                if (err &&
+                    err->domain == VIR_FROM_QEMU &&
                     err->code != VIR_ERR_MIGRATE_FINISH_OK) {
                     virFreeError(orig_err);
                     orig_err = NULL;
-- 
2.1.0




More information about the libvir-list mailing list