From c799cfe577a338324e45ec9a57a418e09697baa4 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Fri, 16 Aug 2024 11:04:01 +0200 Subject: [PATCH] panvk: Fix NULL deref on model name when device isn't supported Instead of reproting an VK_ERROR_INCOMPATIBLE_DRIVER we were crashing as device->model was init after this error check. Tested on G57 but should work the same on all unsupported arch. Signed-off-by: Mary Guillemard Fixes: f7f9b3d170f5 ("panvk: Move to vk_properties") Reviewed-by: Boris Brezillon Part-of: (cherry picked from commit c95ef9e3232ef35da3b3d7a77d0726d0cde3fe23) --- .pick_status.json | 2 +- src/panfrost/vulkan/panvk_physical_device.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 58abaa07dd1..7d249cb28c7 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -144,7 +144,7 @@ "description": "panvk: Fix NULL deref on model name when device isn't supported", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f7f9b3d170f5213d4f20df8ef92827dd97899432", "notes": null diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index 3603d8e7dd5..a5f4381dec4 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -693,6 +693,9 @@ panvk_physical_device_init(struct panvk_physical_device *device, pan_kmod_dev_query_props(device->kmod.dev, &device->kmod.props); + device->model = panfrost_get_model(device->kmod.props.gpu_prod_id, + device->kmod.props.gpu_variant); + unsigned arch = pan_arch(device->kmod.props.gpu_prod_id); if (arch <= 5 || arch >= 8) { @@ -710,8 +713,6 @@ panvk_physical_device_init(struct panvk_physical_device *device, device->master_fd = master_fd; - device->model = panfrost_get_model(device->kmod.props.gpu_prod_id, - device->kmod.props.gpu_variant); device->formats.all = panfrost_format_table(arch); device->formats.blendable = panfrost_blendable_format_table(arch);