Mesa (main): zink: use static array for detecting VK_TIME_DOMAIN_DEVICE_EXT

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 19 00:15:48 UTC 2021


Module: Mesa
Branch: main
Commit: 11dd9e4ee4a5241ee18cfe68d8bee2ee3da55dc7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=11dd9e4ee4a5241ee18cfe68d8bee2ee3da55dc7

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Oct 14 10:13:25 2021 -0400

zink: use static array for detecting VK_TIME_DOMAIN_DEVICE_EXT

there's only a few possible values for this, so just use a static array
to avoid leaking

Fixes: 039078fe972 ("zink: slight refactor of load_device_extensions()")

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13360>

---

 src/gallium/drivers/zink/zink_screen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 5f574010bba..10207633c0a 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1337,10 +1337,11 @@ static bool
 check_have_device_time(struct zink_screen *screen)
 {
    uint32_t num_domains = 0;
+   VkTimeDomainEXT domains[8]; //current max is 4
    VKSCR(GetPhysicalDeviceCalibrateableTimeDomainsEXT)(screen->pdev, &num_domains, NULL);
    assert(num_domains > 0);
+   assert(num_domains < ARRAY_SIZE(domains));
 
-   VkTimeDomainEXT *domains = malloc(sizeof(VkTimeDomainEXT) * num_domains);
    VKSCR(GetPhysicalDeviceCalibrateableTimeDomainsEXT)(screen->pdev, &num_domains, domains);
 
    /* VK_TIME_DOMAIN_DEVICE_EXT is used for the ctx->get_timestamp hook and is the only one we really need */
@@ -1350,7 +1351,6 @@ check_have_device_time(struct zink_screen *screen)
       }
    }
 
-   free(domains);
    return false;
 }
 



More information about the mesa-commit mailing list