drm: fix drmFreeDevices memory leak on multi GPU setups

When in multi GPU case, devices array may have some
NULL "hole" in between two devices. So check all
array elements and free non-NULL device.

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
main
Qiang Yu 2016-07-14 17:10:56 +08:00 committed by Emil Velikov
parent 3c20893daa
commit 6c056eecd5
1 changed files with 3 additions and 2 deletions

View File

@ -2993,7 +2993,8 @@ void drmFreeDevices(drmDevicePtr devices[], int count)
if (devices == NULL)
return;
for (i = 0; i < count && devices[i] != NULL; i++)
for (i = 0; i < count; i++)
if (devices[i])
drmFreeDevice(&devices[i]);
}