diff options
author | Qiang Yu <Qiang.Yu@amd.com> | 2016-07-14 17:10:56 +0800 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2016-07-20 23:44:40 +0100 |
commit | 6c056eecd56374b069ed24c81f59b6638cde2f3a (patch) | |
tree | 67ffe92184b5a2451c81f5af9350a862831db3b2 /xf86drm.c | |
parent | 3c20893daa0a56b91869d806ae0d3a8d5d8b4cba (diff) | |
download | libdrm-6c056eecd56374b069ed24c81f59b6638cde2f3a.tar.gz libdrm-6c056eecd56374b069ed24c81f59b6638cde2f3a.tar.bz2 libdrm-6c056eecd56374b069ed24c81f59b6638cde2f3a.zip |
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.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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, |