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

Commit ec6cd7d5 authored by Harshdeep Dhatt's avatar Harshdeep Dhatt
Browse files

msm: kgsl: Fix context initialization sequence



Re-order the preemption context initialization in order to
avoid NULL pointer dereference if preemption_context_init
fails. Also, correctly handle the failure by removing
the put/kfree as the context will be destroyed in the detach
sequence itself.

Change-Id: Ic8b373da040d39bc412ed54a21f067bd51685f6a
Signed-off-by: default avatarHarshdeep Dhatt <hdhatt@codeaurora.org>
parent a8118139
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -424,16 +424,6 @@ adreno_drawctxt_create(struct kgsl_device_private *dev_priv,
		return ERR_PTR(ret);
	}

	if (gpudev->preemption_context_init) {
		ret = gpudev->preemption_context_init(&drawctxt->base);
		if (ret != 0) {
			kgsl_context_detach(&drawctxt->base);
			kgsl_context_put(&drawctxt->base);
			kfree(drawctxt);
			return ERR_PTR(ret);
		}
	}

	kgsl_sharedmem_writel(device, &device->memstore,
			KGSL_MEMSTORE_OFFSET(drawctxt->base.id, soptimestamp),
			0);
@@ -445,6 +435,14 @@ adreno_drawctxt_create(struct kgsl_device_private *dev_priv,

	INIT_LIST_HEAD(&drawctxt->active_node);

	if (gpudev->preemption_context_init) {
		ret = gpudev->preemption_context_init(&drawctxt->base);
		if (ret != 0) {
			kgsl_context_detach(&drawctxt->base);
			return ERR_PTR(ret);
		}
	}

	/* copy back whatever flags we dediced were valid */
	*flags = drawctxt->base.flags;
	return &drawctxt->base;