radv: Properly handle destroying NULL devices and instances
authorDave Airlie <airlied@redhat.com>
Mon, 6 Mar 2017 05:40:16 +0000 (15:40 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 6 Mar 2017 22:17:03 +0000 (08:17 +1000)
Ported from anv:
3d33a23e anv: Properly handle destroying NULL devices and instances

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_device.c

index 58f37c631f8c187f6241e90e9cab1c56308ef7da..ab04473b01cb7df63e9264b4a78989248d8c8993 100644 (file)
@@ -365,6 +365,9 @@ void radv_DestroyInstance(
 {
        RADV_FROM_HANDLE(radv_instance, instance, _instance);
 
+       if (!instance)
+               return;
+
        for (int i = 0; i < instance->physicalDeviceCount; ++i) {
                radv_physical_device_finish(instance->physicalDevices + i);
        }
@@ -988,6 +991,9 @@ void radv_DestroyDevice(
 {
        RADV_FROM_HANDLE(radv_device, device, _device);
 
+       if (!device)
+               return;
+
        if (device->trace_bo)
                device->ws->buffer_destroy(device->trace_bo);