diff mbox series

[v2,2/2] drm/msm/a6xx: Fix NULL dereference during crashstate capture

Message ID 1544523765-12786-2-git-send-email-smasetty@codeaurora.org (mailing list archive)
State Not Applicable, archived
Headers show
Series [v2,1/2] drm/msm/adreno: Make adreno_gpu_state_get() return void | expand

Commit Message

Sharat Masetty Dec. 11, 2018, 10:22 a.m. UTC
The gpu crashstate's base objects registers pointer can be NULL if the
target implementation decides to capture the register dump on its own.
This patch simply checks for NULL before dereferencing.

Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
---
Changes from v1:
	Addressed comments from Jordan Crouse

 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--
1.9.1
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 40bcf32..56a63c4 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -415,6 +415,9 @@  void adreno_gpu_state_get(struct msm_gpu *gpu, struct msm_gpu_state *state)
 		}
 	}

+	if (!adreno_gpu->registers)
+		return;
+
 	/* Count the number of registers */
 	for (i = 0; adreno_gpu->registers[i] != ~0; i += 2)
 		count += adreno_gpu->registers[i + 1] -
@@ -550,9 +553,10 @@  void adreno_show(struct msm_gpu *gpu, struct msm_gpu_state *state,
 		}
 	}

-	drm_puts(p, "registers:\n");
-
 	for (i = 0; i < state->nr_registers; i++) {
+		if (i == 0)
+			drm_puts(p, "registers:\n");
+
 		drm_printf(p, "  - { offset: 0x%04x, value: 0x%08x }\n",
 			state->registers[i * 2] << 2,
 			state->registers[(i * 2) + 1]);