libvulkan: Fix double-free, refactor instance destruction
Fixes dEQP-VK.api.object_management.alloc_callback_fail.instance. Since we were calling DestroyInstance_Bottom from both CreateInstance_Bottom and CreateInstance_Top failure paths, we were calling the driver's DestroyInstance twice. To avoid such bugs, this change clears the driver instance handle to VK_NULL_HANDLE after calling the driver DestroyInstance. But the real fix in this change is to make creation and destruction symmetric. Now DestroyInstance_Bottom only cleans up the things that were initialized/allocated in CreateInstance_Bottom, and is only called from CreateInstance_Bottom failure paths and from a dispatched vkDestroyInstance. Similarly, DestroyInstance_Top and failure paths in CreateInstance_Top call DestroyInstance (formerly TeardownInstance) to clean up things initialized/allocated in CreateInstance_Top. The direct calls from *_Top functions to DestroyInstance_Bottom are gone -- *_Top functions should only reach *_Bottom functions via dispatch, so the call goes through enabled layers. Bug: 27493757 Change-Id: I4e9f8508297813415499dc17803fff49ce9abdcf (cherry picked from commit 15cd1e269fd2dacef8b95006928b122b9dabbeea)
Loading
Please register or sign in to comment