[Beignet] [PATCH] fix pointer bugs in linked list

Zhigang Gong zhigang.gong at linux.intel.com
Mon Nov 4 07:57:49 CET 2013


Good catch, LGTM, will push it latter.

On Fri, Nov 01, 2013 at 01:53:47PM +0800, Homer Hsing wrote:
> change the header of linked list if the header was deleted
> 
> Signed-off-by: Homer Hsing <homer.xing at intel.com>
> ---
>  src/cl_command_queue.c | 4 ++--
>  src/cl_mem.c           | 4 ++--
>  src/cl_program.c       | 4 ++--
>  src/cl_sampler.c       | 4 ++--
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c
> index 13789f6..768ef0c 100644
> --- a/src/cl_command_queue.c
> +++ b/src/cl_command_queue.c
> @@ -77,8 +77,8 @@ cl_command_queue_delete(cl_command_queue queue)
>        queue->prev->next = queue->next;
>      if (queue->next)
>        queue->next->prev = queue->prev;
> -    if (queue->next == NULL && queue->prev == NULL)
> -      queue->ctx->queues = NULL;
> +    if (queue->ctx->queues == queue)
> +      queue->ctx->queues = queue->next;
>    pthread_mutex_unlock(&queue->ctx->queue_lock);
>    if (queue->fulsim_out != NULL) {
>      cl_mem_delete(queue->fulsim_out);
> diff --git a/src/cl_mem.c b/src/cl_mem.c
> index 5e70ef1..b4c709d 100644
> --- a/src/cl_mem.c
> +++ b/src/cl_mem.c
> @@ -556,8 +556,8 @@ cl_mem_delete(cl_mem mem)
>        mem->prev->next = mem->next;
>      if (mem->next)
>        mem->next->prev = mem->prev;
> -    if (mem->prev == NULL && mem->next == NULL)
> -      mem->ctx->buffers = NULL;
> +    if (mem->ctx->buffers == mem)
> +      mem->ctx->buffers = mem->next;
>    pthread_mutex_unlock(&mem->ctx->buffer_lock);
>    cl_context_delete(mem->ctx);
>  
> diff --git a/src/cl_program.c b/src/cl_program.c
> index b0c29bf..b8da052 100644
> --- a/src/cl_program.c
> +++ b/src/cl_program.c
> @@ -79,8 +79,8 @@ cl_program_delete(cl_program p)
>        p->prev->next = p->next;
>      if (p->next)
>        p->next->prev = p->prev;
> -    if (p->prev == NULL && p->next == NULL)
> -      p->ctx->programs = NULL;
> +    if (p->ctx->programs == p)
> +      p->ctx->programs = p->next;
>    pthread_mutex_unlock(&p->ctx->program_lock);
>  
>    cl_free(p->bin);               /* Free the blob */
> diff --git a/src/cl_sampler.c b/src/cl_sampler.c
> index b3f7045..3e7961f 100644
> --- a/src/cl_sampler.c
> +++ b/src/cl_sampler.c
> @@ -125,8 +125,8 @@ cl_sampler_delete(cl_sampler sampler)
>        sampler->prev->next = sampler->next;
>      if (sampler->next)
>        sampler->next->prev = sampler->prev;
> -    if (sampler->prev == NULL && sampler->next == NULL)
> -      sampler->ctx->samplers = NULL;
> +    if (sampler->ctx->samplers == sampler)
> +      sampler->ctx->samplers = sampler->next;
>    pthread_mutex_unlock(&sampler->ctx->sampler_lock);
>    cl_context_delete(sampler->ctx);
>  
> -- 
> 1.8.3.2
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list