anv: fix possible stack corruption
authorGrazvydas Ignotas <notasas@gmail.com>
Tue, 2 May 2017 16:26:17 +0000 (19:26 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Tue, 9 May 2017 22:13:44 +0000 (01:13 +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: b1fb6e8d "anv: do not open random render node(s)"
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_device.c

index 5e4a62ba57504e2b16f1396f50bc2603498e33a0..a64eae1ac999b3de5444db702bc599e7ed1784b3 100644 (file)
@@ -510,7 +510,7 @@ anv_enumerate_devices(struct anv_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;