evdev problems

Peter Hutterer mailinglists at who-t.net
Wed Mar 21 00:14:18 PDT 2007

On 20/03/2007, at 17:01 , Peter Hutterer wrote:
> I'm not sure what exactly goes wrong. If the ioctl wouldn't fail, I  
> suppose it should work. So why does it fail?

Problem occurs in master too.

With USB keyboards do the following:
1) Send a dbus command to X, evdev will get a ioctl IEVIOCGRAB on the  
device in EvdevNew. Unplug device.
2) Plug device in, evdev will automatically grab it, this time in  
EvdevProc, and also add it to the device list. Nevermind we didn't  
actually send the dbus commands to add it.
3) Send dbus command now. ioctl will fail as the device is already  
grabbed and we have the double-free error as described previously.

Closing the device when a read error occurs removes the problem of  
the double-grab. If a device is closed, it is removed from all  
internal lists. Next time a dbus command comes along it is re- 

diff --git a/src/evdev.c b/src/evdev.c
index 1bcaef8..2ec04f1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -93,7 +93,7 @@ EvdevReadInput(InputInfoPtr pInfo)
		    strerror(errno), errno, len, sizeof (ev));
	    if (len < 0) {
		evdevDevicePtr pEvdev = pInfo->private;
-		pEvdev->callback(pEvdev->pInfo->dev, DEVICE_OFF);
+		pEvdev->callback(pEvdev->pInfo->dev, DEVICE_CLOSE);

This is not a real fix, but I think we need to rewrite parts of evdev  
to fix it properly. This driver-internal hotplugging around the real  
hotplugging mechanism is not good.


Multi-Pointer X Server

More information about the xorg mailing list