From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/msm: Add basic perfcntr infrastructure Date: Thu, 23 Apr 2026 09:13:15 +1000 Message-ID: In-Reply-To: <20260420222621.417276-11-robin.clark@oss.qualcomm.com> References: <20260420222621.417276-1-robin.clark@oss.qualcomm.com> <20260420222621.417276-11-robin.clark@oss.qualcomm.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review Creates `msm_perfcntr.c` with init/cleanup/resume/suspend functions and the global state tracking structures. **Bug -- NULL pointer dereference**: `msm_perfcntr_resume()` and `msm_perfcntr_suspend()` dereference `gpu->perfcntrs->stream` without checking if `gpu->perfcntrs` is NULL: ```c int msm_perfcntr_resume(struct msm_gpu *gpu) { guard(mutex)(&gpu->perfcntr_lock); return msm_perfcntr_resume_locked(gpu->perfcntrs->stream); } ``` Since `gpu->perfcntrs` is only allocated when `num_perfcntr_groups > 0`, and these functions are called unconditionally from `adreno_runtime_resume()`/`adreno_runtime_suspend()` (and `adreno_recover()`), this will crash on any GPU that doesn't set up perfcntr tables (a2xx through a5xx). **Bug -- same issue in `msm_gpu_sysprof_no_perfcntr_zap()`**: ```c static inline bool msm_gpu_sysprof_no_perfcntr_zap(struct msm_gpu *gpu) { return (refcount_read(&gpu->sysprof_active) > 1) || READ_ONCE(gpu->perfcntrs->stream); } ``` Same NULL deref when `gpu->perfcntrs` is NULL. The fix for both is to add a `if (!gpu->perfcntrs)` early-return/guard. **Nit**: `msm_perfcntr_cleanup()` uses `devm_kfree()` which is unusual -- since the memory was allocated with `devm_kzalloc()`, it will be freed automatically at device removal. The explicit `devm_kfree()` is fine for early cleanup, but mixing devm allocation with manual free patterns can be confusing. Consider using plain `kzalloc`/`kfree` since you're managing the lifetime manually anyway. --- Generated by Claude Code Patch Reviewer