msm: kgsl: Fix the race between context create and destroy

Hold the context lock before updating the context id in
param->drawctxt_id to avoid race condition between context
creation and context destroy.

Bug: 36491445
Change-Id: Ic26d3e5b68078c02d15c38080b1a262ea4b1f7fe
Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index d697f06..35c35ba 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -2610,9 +2610,9 @@
 	/* Commit the pointer to the context in context_idr */
 	write_lock(&device->context_lock);
 	idr_replace(&device->context_idr, context, context->id);
+	param->drawctxt_id = context->id;
 	write_unlock(&device->context_lock);
 
-	param->drawctxt_id = context->id;
 done:
 	kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
 	return result;