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

Commit 5856abaa authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Check the return value from ocmem_allocate for error



ocmem_allocate() will soon be changing to return an error code in
some situations. Use IS_ERR_OR_NULL() to avoid the embarrassment of
dereferencing the result of ERR_PTR() by mistake.

Change-Id: Ic0dedbadbb630d276b9abfdd4bef2f328794c4e6
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 9d6495a8
Loading
Loading
Loading
Loading
+14 −21
Original line number Diff line number Diff line
@@ -1396,17 +1396,17 @@ adreno_ocmem_gmem_malloc(struct adreno_device *adreno_dev)
		adreno_is_a4xx(adreno_dev)))
		return 0;

	/* OCMEM is only needed once, do not support consective allocation */
	if (adreno_dev->ocmem_hdl != NULL)
		return 0;

	if (adreno_dev->ocmem_hdl == NULL) {
		adreno_dev->ocmem_hdl =
			ocmem_allocate(OCMEM_GRAPHICS, adreno_dev->gmem_size);
	if (adreno_dev->ocmem_hdl == NULL)
		if (IS_ERR_OR_NULL(adreno_dev->ocmem_hdl)) {
			adreno_dev->ocmem_hdl = NULL;
			return -ENOMEM;
		}

		adreno_dev->gmem_size = adreno_dev->ocmem_hdl->len;
		adreno_dev->ocmem_base = adreno_dev->ocmem_hdl->addr;
	}

	return 0;
}
@@ -1414,18 +1414,11 @@ adreno_ocmem_gmem_malloc(struct adreno_device *adreno_dev)
static void
adreno_ocmem_gmem_free(struct adreno_device *adreno_dev)
{
	if (!(adreno_is_a330(adreno_dev) ||
		adreno_is_a305b(adreno_dev) ||
		adreno_is_a310(adreno_dev) ||
		adreno_is_a4xx(adreno_dev)))
		return;

	if (adreno_dev->ocmem_hdl == NULL)
		return;

	if (adreno_dev->ocmem_hdl != NULL) {
		ocmem_free(OCMEM_GRAPHICS, adreno_dev->ocmem_hdl);
		adreno_dev->ocmem_hdl = NULL;
	}
}
#else
static int
adreno_ocmem_gmem_malloc(struct adreno_device *adreno_dev)