[PATCH libinput 09/17] evdev: prevent double-suspending a device

Peter Hutterer peter.hutterer at who-t.net
Tue Sep 2 19:03:00 PDT 2014


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 054beb6..9e91ee5 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1168,16 +1168,23 @@ release_pressed_keys(struct evdev_device *device)
 int
 evdev_device_suspend(struct evdev_device *device)
 {
-	if (device->source)
+	if (device->source) {
 		libinput_remove_source(device->base.seat->libinput,
 				       device->source);
+		device->source = NULL;
+	}
 
 	release_pressed_keys(device);
 
-	if (device->mtdev)
+	if (device->mtdev) {
 		mtdev_close_delete(device->mtdev);
-	close_restricted(device->base.seat->libinput, device->fd);
-	device->fd = -1;
+		device->mtdev = NULL;
+	}
+
+	if (device->fd != -1) {
+		close_restricted(device->base.seat->libinput, device->fd);
+		device->fd = -1;
+	}
 
 	return 0;
 }
-- 
1.9.3



More information about the wayland-devel mailing list