[PATCH xf86-input-libinput] Bail when a sub-device is it's own parent

Peter Hutterer peter.hutterer at who-t.net
Mon Aug 15 00:39:22 UTC 2016


On Sat, Aug 13, 2016 at 09:28:20AM -0700, Keith Packard wrote:
> I don't understand when or how this can happen, but 'make check' in
> libinput causes this many times:
> 
> [ 68331.672] (EE) libinput: litest ROCCAT ROCCAT Kone XTD: Parent device is self?
 
[...]

> This is *not* a fix, simply a kludge that notices when it happens and
> keeps things working in spite of this mistake.

I think I understand why: there is a bug in xf86libinput_get_parent() in
that it doesn't actually check for a parent device, it just checks for the
shared-device setting (which is set on *both* the parent and the child). The
sequence to trigger is:

* parent pre_init, sets shared-device, schedules child hotplug
* parent is removed
* child hotplug callback is called, searches for the first device with the
  shared-device option set

We're using xf86FirstLocalDevice() which uses xf86InputDevs, not
inputInfo.devices. xf86InputDevs adds a new device on allocation, not on
DEVICE_ON, so our new child device is already in the list by the time we get
here.

The current code worked because the list is appended to and our parent is
always the first match. but if the parent gets removed before the hotplug
callback the first match is our own device. The fix to this is simply
checking not just for the deviceid but also that the match we have isn't a
subdevice. I'll get a patch for that out in a tick.

Cheers,
   Peter

> 
> Signed-off-by: Keith Packard <keithp at keithp.com>
> ---
>  src/xf86libinput.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/xf86libinput.c b/src/xf86libinput.c
> index 45385f7..9be4354 100644
> --- a/src/xf86libinput.c
> +++ b/src/xf86libinput.c
> @@ -2589,6 +2589,10 @@ xf86libinput_pre_init(InputDriverPtr drv,
>  			xf86IDrvMsg(pInfo, X_ERROR, "Failed to find parent device\n");
>  			goto fail;
>  		}
> +		if (parent == pInfo) {
> +			xf86IDrvMsg(pInfo, X_ERROR, "Parent device is self?\n");
> +			goto fail;
> +		}
>  		xf86IDrvMsg(pInfo, X_INFO, "is a virtual subdevice\n");
>  
>  		parent_driver_data = parent->private;
> -- 
> 2.8.1
> 


More information about the xorg-devel mailing list