6ae9ed
From 00cc1b75dd5933bc68236ebc417fc816c4f45651 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <00cc1b75dd5933bc68236ebc417fc816c4f45651@dist-git>
6ae9ed
From: Michal Privoznik <mprivozn@redhat.com>
6ae9ed
Date: Fri, 5 Aug 2016 16:34:37 +0200
6ae9ed
Subject: [PATCH] lxcDomainCreateXMLWithFiles: Avoid crash
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1363773
6ae9ed
6ae9ed
Imagine that you're creating a transient domain, but for some reason,
6ae9ed
starting it fails. That is virLXCProcessStart() returns an error. With
6ae9ed
current code, in the error handling code the domain object is removed
6ae9ed
from the domain object list, @vm is set to NULL and controls jump to
6ae9ed
enjob label where virLXCDomainObjEndJob() is called which dereference vm
6ae9ed
leading to instant crash.
6ae9ed
6ae9ed
The fix is to end the job in the error handling code and only after that
6ae9ed
remove the domain from the list and jump onto cleanup label instead of
6ae9ed
endjob.
6ae9ed
6ae9ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6ae9ed
(cherry picked from commit 5f5a5a42e5146336430b9284539d4bff3e8bb598)
6ae9ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6ae9ed
---
6ae9ed
 src/lxc/lxc_driver.c | 4 ++--
6ae9ed
 1 file changed, 2 insertions(+), 2 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
6ae9ed
index 80b7a5c..d47f215 100644
6ae9ed
--- a/src/lxc/lxc_driver.c
6ae9ed
+++ b/src/lxc/lxc_driver.c
6ae9ed
@@ -1265,11 +1265,12 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
6ae9ed
                            (flags & VIR_DOMAIN_START_AUTODESTROY),
6ae9ed
                            VIR_DOMAIN_RUNNING_BOOTED) < 0) {
6ae9ed
         virDomainAuditStart(vm, "booted", false);
6ae9ed
+        virLXCDomainObjEndJob(driver, vm);
6ae9ed
         if (!vm->persistent) {
6ae9ed
             virDomainObjListRemove(driver->domains, vm);
6ae9ed
             vm = NULL;
6ae9ed
         }
6ae9ed
-        goto endjob;
6ae9ed
+        goto cleanup;
6ae9ed
     }
6ae9ed
 
6ae9ed
     event = virDomainEventLifecycleNewFromObj(vm,
6ae9ed
@@ -1281,7 +1282,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
6ae9ed
     if (dom)
6ae9ed
         dom->id = vm->def->id;
6ae9ed
 
6ae9ed
- endjob:
6ae9ed
     virLXCDomainObjEndJob(driver, vm);
6ae9ed
 
6ae9ed
  cleanup:
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed