summaryrefslogtreecommitdiff
path: root/xf86drm.c
diff options
context:
space:
mode:
authorQiang Yu <Qiang.Yu@amd.com>2016-07-14 17:10:56 +0800
committerEmil Velikov <emil.l.velikov@gmail.com>2016-07-20 23:44:40 +0100
commit6c056eecd56374b069ed24c81f59b6638cde2f3a (patch)
tree67ffe92184b5a2451c81f5af9350a862831db3b2 /xf86drm.c
parent3c20893daa0a56b91869d806ae0d3a8d5d8b4cba (diff)
downloaddrm-6c056eecd56374b069ed24c81f59b6638cde2f3a.tar.gz
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>
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c5
1 files 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,