radv: fix possible stack corruption
authorGrazvydas Ignotas <notasas@gmail.com>
Tue, 2 May 2017 16:41:13 +0000 (19:41 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Wed, 3 May 2017 19:02:45 +0000 (22:02 +0300)
drmGetDevices2 takes count and not size. Probably hasn't caused problems
yet in practice and was missed as setups with more than 8 DRM devices
are not very common.

Fixes: 743315f2 "radv: do not open random render node(s)"
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_device.c

index 408c034..9e66faf 100644 (file)
@@ -401,7 +401,7 @@ radv_enumerate_devices(struct radv_instance *instance)
 
        instance->physicalDeviceCount = 0;
 
-       max_devices = drmGetDevices2(0, devices, sizeof(devices));
+       max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
        if (max_devices < 1)
                return VK_ERROR_INCOMPATIBLE_DRIVER;