OSDN Git Service

xf86drm: Fix error handling for drmGetDevices()
authorMatt Roper <matthew.d.roper@intel.com>
Wed, 30 Sep 2015 16:30:51 +0000 (09:30 -0700)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 2 Oct 2015 12:17:03 +0000 (13:17 +0100)
commit8c4a1cbd98bd8d185d489395f33302a17db643a9
tree1ae4b0f509400996c93d50e977e99ce9be5da392
parent4031dc17bb728850c9b079c8d5f9cc0a379b9d46
xf86drm: Fix error handling for drmGetDevices()

If the opendir() call in drmGetDevices() returns failure, we jump to an
error label that calls closedir() and then returns.  However this means
that we're calling closedir(NULL) which may not be safe on all
implementations.  We are also leaking the local_devices array that was
allocated before the opendir() call.

Fix both of these issues by jumping to an earlier error label (to free
local_devices) and guarding the closedir() call with a NULL test.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
[Emil Velikov: make the teardown symmetrical, remove the NULL check]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
xf86drm.c