]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Fix crash when updating media with shared device
authorPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2013 21:15:00 +0000 (23:15 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2013 21:15:00 +0000 (23:15 +0200)
Mimic the fix done in 02b9097274d1330c2e1dca7f598880e09b5c2aa0 to fix crash by
accessing an already freed structure. Also copy the explaining comment why the
pointer can't be accessed any more.

src/qemu/qemu_driver.c

index 96bf23503b9efd7a5109c093719e3ce562510734..552a81b22efb943b6cbb9392f6a19dbd0862fa96 100644 (file)
@@ -6073,14 +6073,17 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm,
             goto end;
 
         ret = qemuDomainChangeEjectableMedia(driver, vm, disk, orig_disk, force);
+        /* 'disk' must not be accessed now - it has been freed.
+         * 'orig_disk' now points to the new disk, while 'dev_copy'
+         * now points to the old disk */
+
+        /* Need to remove the shared disk entry for the original
+         * disk src if the operation is either ejecting or updating.
+         */
         if (ret == 0) {
             dev->data.disk = NULL;
-            /* Need to remove the shared disk entry for the original
-             * disk src if the operation is either ejecting or updating.
-             */
-            if (orig_disk->src && STRNEQ_NULLABLE(orig_disk->src, disk->src))
-                ignore_value(qemuRemoveSharedDisk(driver, dev_copy->data.disk,
-                                                  vm->def->name));
+            ignore_value(qemuRemoveSharedDisk(driver, dev_copy->data.disk,
+                                              vm->def->name));
         }
         break;
     default: