diff --git a/drivers/gpu/msm/kgsl_events.c b/drivers/gpu/msm/kgsl_events.c index 20025377ad1c..3ea8f4bb0929 100644 --- a/drivers/gpu/msm/kgsl_events.c +++ b/drivers/gpu/msm/kgsl_events.c @@ -80,6 +80,10 @@ int kgsl_add_event(struct kgsl_device *device, u32 id, u32 ts, event->func = cb; event->owner = owner; + /* inc refcount to avoid race conditions in cleanup */ + if (context) + kgsl_context_get(context); + /* Add the event to either the owning context or the global list */ if (context) { @@ -127,6 +131,7 @@ void kgsl_cancel_events_ctxt(struct kgsl_device *device, if (event->func) event->func(device, event->priv, id, cur); + kgsl_context_put(context); list_del(&event->list); kfree(event); } @@ -163,6 +168,9 @@ void kgsl_cancel_events(struct kgsl_device *device, event->func(device, event->priv, KGSL_MEMSTORE_GLOBAL, cur); + if (event->context) + kgsl_context_put(event->context); + list_del(&event->list); kfree(event); } @@ -184,6 +192,9 @@ static void _process_event_list(struct kgsl_device *device, if (event->func) event->func(device, event->priv, id, timestamp); + if (event->context) + kgsl_context_put(event->context); + list_del(&event->list); kfree(event); }