[PATCH] devices: break after finding and removing device from lists

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 12 02:09:47 UTC 2018


On Wed, Sep 12, 2018 at 11:40:56AM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> Coverity complains about a use after free in here after the
> freeing, I can't follow the linked list so well, but whot
> says the device can only be on one list once, so break should
> fix it.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>

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

Cheers,
   Peter

> ---
>  dix/devices.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/dix/devices.c b/dix/devices.c
> index 4a628afb0..1b18b168e 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -1177,6 +1177,7 @@ RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
>              flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
>              CloseDevice(tmp);
>              ret = Success;
> +            break;
>          }
>      }
>  
> @@ -1193,6 +1194,7 @@ RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
>                  prev->next = next;
>  
>              ret = Success;
> +            break;
>          }
>      }
>  
> -- 
> 2.17.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