anv: Don't teardown uninitialized anv_physical_device
authorChad Versace <chad.versace@intel.com>
Wed, 21 Oct 2015 18:36:39 +0000 (11:36 -0700)
committerChad Versace <chad.versace@intel.com>
Wed, 21 Oct 2015 18:55:37 +0000 (11:55 -0700)
If the user called vkDestroyDevice but never called
vkEnumeratePhysicalDevices, then the driver tried to ralloc_free() an
unitialized anv_physical_device.

Fixes test 'dEQP-VK.api.device_init.create_instance_name_version'.

src/vulkan/anv_device.c

index fd87c85b0cebd0bdc52568dfd45172964c961872..d450b2b4e872f92b1d4082579a83be2c22e80877 100644 (file)
@@ -224,7 +224,12 @@ void anv_DestroyInstance(
 {
    ANV_FROM_HANDLE(anv_instance, instance, _instance);
 
-   anv_physical_device_finish(&instance->physicalDevice);
+   if (instance->physicalDeviceCount > 0) {
+      /* We support at most one physical device. */
+      assert(instance->physicalDeviceCount == 1);
+      anv_physical_device_finish(&instance->physicalDevice);
+   }
+
    anv_finish_wsi(instance);
 
    VG(VALGRIND_DESTROY_MEMPOOL(instance));