aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQiang Yu2016-07-14 04:10:56 -0500
committerEmil Velikov2016-07-20 17:44:40 -0500
commit6c056eecd56374b069ed24c81f59b6638cde2f3a (patch)
tree67ffe92184b5a2451c81f5af9350a862831db3b2 /xf86drm.c
parent3c20893daa0a56b91869d806ae0d3a8d5d8b4cba (diff)
downloadexternal-libdrm-6c056eecd56374b069ed24c81f59b6638cde2f3a.tar.gz
external-libdrm-6c056eecd56374b069ed24c81f59b6638cde2f3a.tar.xz
external-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.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)
2993 if (devices == NULL) 2993 if (devices == NULL)
2994 return; 2994 return;
2995 2995
2996 for (i = 0; i < count && devices[i] != NULL; i++) 2996 for (i = 0; i < count; i++)
2997 drmFreeDevice(&devices[i]); 2997 if (devices[i])
2998 drmFreeDevice(&devices[i]);
2998} 2999}
2999 3000
3000static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, 3001static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name,