[Beignet] [PATCH] runtime: Fix a dangling pointer issue
Xing, Homer
homer.xing at intel.com
Thu Oct 31 04:04:19 CET 2013
This patch looks good to me.
-----Original Message-----
From: beignet-bounces at lists.freedesktop.org [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Ruiling Song
Sent: Thursday, October 31, 2013 11:01 AM
To: beignet at lists.freedesktop.org
Cc: Song, Ruiling
Subject: [Beignet] [PATCH] runtime: Fix a dangling pointer issue
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