Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2f18944 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Avoid racing against context delete while releasing contexts"

parents e7f4f7d6 d6a49f7b
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -1072,25 +1072,28 @@ static void device_release_contexts(struct kgsl_device_private *dev_priv)
	struct kgsl_device *device = dev_priv->device;
	struct kgsl_context *context;
	int next = 0;
	int result = 0;

	while (1) {
		read_lock(&device->context_lock);
		context = idr_get_next(&device->context_idr, &next);
		read_unlock(&device->context_lock);

		if (context == NULL)
		if (context == NULL) {
			read_unlock(&device->context_lock);
			break;

		if (context->dev_priv == dev_priv) {
		} else if (context->dev_priv == dev_priv) {
			/*
			 * Hold a reference to the context in case somebody
			 * tries to put it while we are detaching
			 */
			result = _kgsl_context_get(context);
		}
		read_unlock(&device->context_lock);

			if (_kgsl_context_get(context)) {
		if (result) {
			kgsl_context_detach(context);
			kgsl_context_put(context);
			}
			result = 0;
		}

		next = next + 1;