Mesa (main): radv: fix accessing NULL pointers when destroy the VRS image
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 29 08:48:38 UTC 2021
Module: Mesa
Branch: main
Commit: a58f68fc68fae9c60c56c9111244212facbbd7d4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a58f68fc68fae9c60c56c9111244212facbbd7d4
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Fri Nov 26 16:14:30 2021 +0100
radv: fix accessing NULL pointers when destroy the VRS image
Detected by UBSAN.
../src/amd/vulkan/radv_private.h:2939:1: runtime error: member access
within null pointer of type 'struct radv_device_memory'
../src/amd/vulkan/radv_private.h:2926:1: runtime error: member access
within null pointer of type 'struct radv_buffer'
../src/amd/vulkan/radv_private.h:2945:1: runtime error: member access
within null pointer of type 'struct radv_image'
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13965>
---
src/amd/vulkan/radv_device.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 0c21a34e5a4..9846c78c724 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2863,6 +2863,9 @@ fail_create:
static void
radv_device_finish_vrs_image(struct radv_device *device)
{
+ if (!device->vrs.image)
+ return;
+
radv_FreeMemory(radv_device_to_handle(device), radv_device_memory_to_handle(device->vrs.mem),
&device->meta_state.alloc);
radv_DestroyBuffer(radv_device_to_handle(device), radv_buffer_to_handle(device->vrs.buffer),
More information about the mesa-commit
mailing list