[PATCH xserver] os: fix input_mutex_count off-by-one in input_force_unlock

Peter Hutterer peter.hutterer at who-t.net
Mon May 30 02:08:18 UTC 2016


On Sun, May 29, 2016 at 01:19:21AM -0700, Keith Packard wrote:
> input_force_unlock was mis-using input_mutex_lock and leaving it set
> to -1. As this is  executed from OsInit at each server generation, on
> the second time through, the mutex would be left locked (!) due to the
> trylock call. This caused input to fail after the first server reset.
> 
> Signed-off-by: Keith Packard <keithp at keithp.com>

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
   Peter
> ---
>  os/inputthread.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/os/inputthread.c b/os/inputthread.c
> index b6bbf35..390b66b 100644
> --- a/os/inputthread.c
> +++ b/os/inputthread.c
> @@ -109,9 +109,10 @@ void
>  input_force_unlock(void)
>  {
>      if (pthread_mutex_trylock(&input_mutex) == 0) {
> +        input_mutex_count++;
>          /* unlock +1 times for the trylock */
> -        while (input_mutex_count-- >= 0)
> -            pthread_mutex_unlock(&input_mutex);
> +        while (input_mutex_count > 0)
> +            input_unlock();
>      }
>  }
>  
> -- 
> 2.8.1
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list