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

Commit eeeaaa77 authored by Carter Cooper's avatar Carter Cooper Committed by Gerrit - the friendly Code Review server
Browse files

msm: kgsl: Properly check error codes when allocating ringbuffer space



Failure to allocate space can return error codes as well as NULL. Check
for both of these conditions when trying to allocate space for commands
in the ringbuffer.

Change-Id: Id1b025a2478ab9ee2c22959aeb2a5d83f54d943a
Signed-off-by: default avatarCarter Cooper <ccooper@codeaurora.org>
parent 402a576f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -680,8 +680,10 @@ int a3xx_rb_init(struct adreno_device *adreno_dev,
{
	unsigned int *cmds;
	cmds = adreno_ringbuffer_allocspace(rb, NULL, 18);
	if (IS_ERR(cmds))
		return PTR_ERR(cmds);
	if (cmds == NULL)
		return -ENOMEM;
		return -ENOSPC;

	*cmds++ = cp_type3_packet(CP_ME_INIT, 17);

+3 −2
Original line number Diff line number Diff line
@@ -386,8 +386,10 @@ static int _ringbuffer_bootstrap_ucode(struct adreno_ringbuffer *rb,
	adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_CNTL, 0);

	cmds = adreno_ringbuffer_allocspace(rb, NULL, bootstrap_size);
	if (IS_ERR(cmds))
		return PTR_ERR(cmds);
	if (cmds == NULL)
			return -ENOMEM;
		return -ENOSPC;

	/* Construct the packet that bootsraps the ucode */
	*cmds++ = cp_type3_packet(CP_BOOTSTRAP_UCODE, (bootstrap_size - 1));
@@ -780,7 +782,6 @@ adreno_ringbuffer_addcmds(struct adreno_ringbuffer *rb,
		total_sizedwords += 9;

	ringcmds = adreno_ringbuffer_allocspace(rb, drawctxt, total_sizedwords);

	if (IS_ERR(ringcmds))
		return PTR_ERR(ringcmds);
	if (ringcmds == NULL)