Skip to content

Commit 3099e02

Browse files
haryvenRob Clark
authored andcommitted
drm/msm: Fix NULL pointer dereference in crashstate_get_vm_logs()
crashstate_get_vm_logs() did not check the return value of kmalloc_array(). In low-memory situations, kmalloc_array() may return NULL, leading to a NULL pointer dereference when the function later accesses state->vm_logs. Fix this by checking the return value of kmalloc_array() and setting state->nr_vm_logs to 0 if allocation fails. Fixes: 9edc529 ("drm/msm: Add VM logging for VM_BIND updates") Signed-off-by: Huiwen He <hehuiwen@kylinos.cn> Patchwork: https://patchwork.freedesktop.org/patch/687555/ Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
1 parent 15cc59a commit 3099e02

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ static void crashstate_get_vm_logs(struct msm_gpu_state *state, struct msm_gem_v
348348

349349
state->vm_logs = kmalloc_array(
350350
state->nr_vm_logs, sizeof(vm->log[0]), GFP_KERNEL);
351+
if (!state->vm_logs) {
352+
state->nr_vm_logs = 0;
353+
}
354+
351355
for (int i = 0; i < state->nr_vm_logs; i++) {
352356
int idx = (i + first) & vm_log_mask;
353357

0 commit comments

Comments
 (0)