From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/msm: Add basic perfcntr infrastructure
Date: Thu, 23 Apr 2026 09:13:15 +1000 [thread overview]
Message-ID: <review-patch10-20260420222621.417276-11-robin.clark@oss.qualcomm.com> (raw)
In-Reply-To: <20260420222621.417276-11-robin.clark@oss.qualcomm.com>
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
next prev parent reply other threads:[~2026-04-22 23:13 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 22:25 [PATCH 00/13] drm/msm: Add PERFCNTR_CONFIG ioctl Rob Clark
2026-04-20 22:25 ` [PATCH 01/13] drm/msm: Remove obsolete perf infrastructure Rob Clark
2026-04-20 23:49 ` Dmitry Baryshkov
2026-04-21 13:07 ` Rob Clark
2026-04-21 15:39 ` Dmitry Baryshkov
2026-04-21 20:48 ` Rob Clark
2026-04-22 0:41 ` Dmitry Baryshkov
2026-04-22 14:41 ` Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 02/13] drm/msm/adreno: Sync registers from mesa Rob Clark
2026-04-20 23:50 ` Dmitry Baryshkov
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 03/13] drm/msm/registers: Sync gen_header.py " Rob Clark
2026-04-22 3:39 ` Dmitry Baryshkov
2026-04-22 13:36 ` Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 04/13] drm/msm/registers: Add perfcntr json Rob Clark
2026-04-22 3:34 ` Dmitry Baryshkov
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 05/13] drm/msm: Allow CAP_PERFMON for setting SYSPROF Rob Clark
2026-04-21 1:55 ` Dmitry Baryshkov
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 06/13] drm/msm: Add a6xx+ perfcntr tables Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 07/13] drm/msm: Add sysprof accessors Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 08/13] drm/msm/a6xx: Add yield & flush helper Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 09/13] drm/msm: Add per-context perfcntr state Rob Clark
2026-04-22 3:37 ` Dmitry Baryshkov
2026-04-22 14:13 ` Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 10/13] drm/msm: Add basic perfcntr infrastructure Rob Clark
2026-04-22 23:13 ` Claude Code Review Bot [this message]
2026-04-20 22:25 ` [PATCH 11/13] drm/msm/a6xx+: Add support to configure perfcntrs Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 12/13] drm/msm/a8xx: Add perfcntr flush sequence Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-20 22:25 ` [PATCH 13/13] drm/msm: Add PERFCNTR_CONFIG ioctl Rob Clark
2026-04-22 3:41 ` Dmitry Baryshkov
2026-04-22 14:20 ` Rob Clark
2026-04-22 17:48 ` Dmitry Baryshkov
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-22 1:54 ` [PATCH 00/13] " Dmitry Baryshkov
2026-04-22 17:29 ` Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-04 19:06 [PATCH v3 00/16] " Rob Clark
2026-05-04 19:06 ` [PATCH v3 10/16] drm/msm: Add basic perfcntr infrastructure Rob Clark
2026-05-04 22:06 ` Claude review: " Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=review-patch10-20260420222621.417276-11-robin.clark@oss.qualcomm.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox