[Beignet] [PATCH] runtime: Fix a dangling pointer issue
Zhigang Gong
zhigang.gong at linux.intel.com
Thu Oct 31 05:40:37 CET 2013
Pushed, thanks.
On Thu, Oct 31, 2013 at 11:01:21AM +0800, Ruiling Song wrote:
> ctx->events points to the head of 'event list' under the ctx.
> When deleting an event from the list, we should also update
> the head pointer besides updating its neighbour's next & prev,
>
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
> src/cl_event.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/src/cl_event.c b/src/cl_event.c
> index 212f1ee..1dc02ae 100644
> --- a/src/cl_event.c
> +++ b/src/cl_event.c
> @@ -124,12 +124,15 @@ void cl_event_delete(cl_event event)
> /* Remove it from the list */
> assert(event->ctx);
> pthread_mutex_lock(&event->ctx->event_lock);
> - if (event->prev)
> - event->prev->next = event->next;
> - if (event->next)
> - event->next->prev = event->prev;
> - if (event->prev == NULL && event->next == NULL)
> - event->ctx->events = NULL;
> +
> + if (event->prev)
> + event->prev->next = event->next;
> + if (event->next)
> + event->next->prev = event->prev;
> + /* if this is the head, update head pointer ctx->events */
> + if (event->ctx->events == event)
> + event->ctx->events = event->next;
> +
> pthread_mutex_unlock(&event->ctx->event_lock);
> cl_context_delete(event->ctx);
>
> --
> 1.7.9.5
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list