[PATCH evdev 1/2] Release leaked XKB options on input device disconnect.

Peter Hutterer peter.hutterer at who-t.net
Sun Mar 6 16:23:14 PST 2011


On Fri, Mar 04, 2011 at 01:18:53PM +0200, Rami Ylimäki wrote:
> Currently the XKB options duplicated in EvdevAddKeyClass are never
> released. For example, connecting and disconnecting a bluetooth
> keyboard repeatedly causes a steadily growing memory leak.
> 
> Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
> Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
> ---
>  src/evdev.c |   19 ++++++++++++++++++-
>  1 files changed, 18 insertions(+), 1 deletions(-)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index bb30655..a77be9e 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1826,6 +1826,23 @@ EvdevOpenDevice(InputInfoPtr pInfo)
>      return Success;
>  }
>  
> +static void
> +EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
> +{
> +    EvdevPtr pEvdev = pInfo ? pInfo->private : NULL;
> +    if (pEvdev)
> +    {
> +        /* Release strings allocated in EvdevAddKeyClass. */
> +        free(pEvdev->rmlvo.rules);
> +        free(pEvdev->rmlvo.model);
> +        free(pEvdev->rmlvo.layout);
> +        free(pEvdev->rmlvo.variant);
> +        free(pEvdev->rmlvo.options);
> +        memset(&pEvdev->rmlvo, 0, sizeof(pEvdev->rmlvo));

this should be done done with XkbFreeRMLVOSet()

Cheers,
  Peter

> +    }


> +    xf86DeleteInput(pInfo, flags);
> +}
> +
>  static int
>  EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
>  {
> @@ -1897,7 +1914,7 @@ _X_EXPORT InputDriverRec EVDEV = {
>      "evdev",
>      NULL,
>      EvdevPreInit,
> -    NULL,
> +    EvdevUnInit,
>      NULL,
>      evdevDefaults
>  };
> -- 
> 1.6.3.3


More information about the xorg-devel mailing list