From ea3c5f25eb94f08d2a54385362c7ad60c6b1854e Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Tue, 1 Sep 2015 06:47:55 -0400 Subject: [PATCH] qemu: Check virGetLastError return value for migration finish failure 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. --- 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 cbf08fc8c8..964a4d7806 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 ff89ab5f1e..d50d3675d7 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;