aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-01-11 21:43:12 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-01-13 18:51:49 +0100
commit093846aaea3da28f2227f8c300ee807edd5c1ff4 (patch)
tree0d498f3c1bbd1e0e31676bd17dda2fb9c544b392 /src/lib/ecore_drm
parenteina: add all test cases for eina_vector2. (diff)
downloadefl-093846aaea3da28f2227f8c300ee807edd5c1ff4.tar.gz
ecore_drm: check if device is already opened before open and free
check if fd is -1 before opening a device, so a device cannot be opened twice. Also check if fd is != -1 before closing it.
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/ecore_drm_device.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c
index 5376dbd886..1b7fc8b7b0 100644
--- a/src/lib/ecore_drm/ecore_drm_device.c
+++ b/src/lib/ecore_drm/ecore_drm_device.c
@@ -237,6 +237,7 @@ cont:
if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
{
+ dev->drm.fd = -1;
dev->drm.name = eeze_udev_syspath_get_devpath(device);
dev->drm.path = eina_stringshare_add(device);
@@ -314,8 +315,15 @@ ecore_drm_device_open(Ecore_Drm_Device *dev)
/* check for valid device */
if ((!dev) || (!dev->drm.name)) return EINA_FALSE;
+ /* check if device is already opened */
+ if (dev->drm.fd != -1)
+ {
+ ERR("Device is already opened");
+ return EINA_FALSE;
+ }
+
/* DRM device node is needed immediately to keep going. */
- dev->drm.fd =
+ dev->drm.fd =
_ecore_drm_launcher_device_open_no_pending(dev->drm.name, O_RDWR);
if (dev->drm.fd < 0) return EINA_FALSE;
@@ -382,12 +390,15 @@ ecore_drm_device_open(Ecore_Drm_Device *dev)
return EINA_TRUE;
}
-EAPI Eina_Bool
+EAPI Eina_Bool
ecore_drm_device_close(Ecore_Drm_Device *dev)
{
/* check for valid device */
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
+ /* check if device is opened */
+ if (dev->drm.fd == -1) return EINA_FALSE;
+
/* delete udev watch */
if (dev->watch) eeze_udev_watch_del(dev->watch);