From 6c056eecd56374b069ed24c81f59b6638cde2f3a Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Thu, 14 Jul 2016 17:10:56 +0800 Subject: [PATCH] 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 Reviewed-by: Emil Velikov --- xf86drm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index 9bd82b2c..9cfca49d 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2993,8 +2993,9 @@ void drmFreeDevices(drmDevicePtr devices[], int count) if (devices == NULL) return; - for (i = 0; i < count && devices[i] != NULL; i++) - drmFreeDevice(&devices[i]); + for (i = 0; i < count; i++) + if (devices[i]) + drmFreeDevice(&devices[i]); } static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name,