From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm: i915: selftests: fix oa_config refcount leak in test_stream()
Date: Thu, 28 May 2026 12:42:29 +1000 [thread overview]
Message-ID: <review-patch1-20260527040835.854065-1-vulab@iscas.ac.cn> (raw)
In-Reply-To: <20260527040835.854065-1-vulab@iscas.ac.cn>
Patch Review
**Bug: NULL pointer dereference introduced**
The original code correctly checked `props.engine` before dereferencing it:
```c
if (!props.engine)
return NULL;
gt = props.engine->gt;
```
The patch removes that guard and moves it *after* the dereference:
```diff
- if (!props.engine)
- return NULL;
-
gt = props.engine->gt;
if (!oa_config)
return NULL;
+ if (!props.engine) {
+ i915_oa_config_put(oa_config);
+ return NULL;
+ }
```
If `props.engine` is NULL, line `gt = props.engine->gt;` will dereference a NULL pointer and crash before ever reaching the new `if (!props.engine)` check. This makes the new guard dead code and introduces a kernel oops on the path it claims to fix.
**The original bug is real but minor.** The commit message correctly identifies that when `props.engine` is non-NULL but `oa_config` is NULL, or when `props.engine` is NULL, there are paths that leak the `oa_config` refcount. However:
1. This is selftest code, not production driver code.
2. `props.engine` being NULL requires `intel_engine_lookup_user()` to fail for render engine class 0, which is unlikely on any system actually running i915 selftests.
**Correct fix approach.** The proper fix keeps the engine check first (before the dereference) and simply adds the refcount release:
```c
if (!props.engine) {
i915_oa_config_put(oa_config);
return NULL;
}
gt = props.engine->gt;
if (!oa_config)
return NULL;
```
Note that `i915_oa_config_put()` already handles NULL (`i915_perf.h:54`), so no additional NULL check on `oa_config` is needed before calling it.
**Cc: stable is unwarranted.** This is a selftest-only refcount leak with no user-visible impact; backporting to stable is unnecessary.
**Fixes tag validity.** The referenced commit `9677a9f3b1ad` is plausible as the commit that restructured perf data, but the leak predates it — the original code never released `oa_config` on the `!props.engine` path regardless. This may need a different or additional Fixes tag.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-05-28 2:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 4:08 [PATCH] drm: i915: selftests: fix oa_config refcount leak in test_stream() Wentao Liang
2026-05-28 2:42 ` Claude review: " Claude Code Review Bot
2026-05-28 2:42 ` Claude Code Review Bot [this message]
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-patch1-20260527040835.854065-1-vulab@iscas.ac.cn \
--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