From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/amdgpu: Switch private_obj initialization to atomic_create_state
Date: Fri, 27 Feb 2026 15:05:37 +1000 [thread overview]
Message-ID: <review-patch1-20260224-drm-private-obj-reset-v5-1-5a72f8ec9934@kernel.org> (raw)
In-Reply-To: <20260224-drm-private-obj-reset-v5-1-5a72f8ec9934@kernel.org>
Patch Review
**Commit message**: Clear and well-written.
**Code review**:
The new `dm_atomic_create_state()` function looks correct:
```c
static struct drm_private_state *
dm_atomic_create_state(struct drm_private_obj *obj)
{
struct amdgpu_device *adev = drm_to_adev(obj->dev);
struct dm_atomic_state *dm_state;
struct dc_state *context;
dm_state = kzalloc_obj(*dm_state);
if (!dm_state)
return ERR_PTR(-ENOMEM);
context = dc_state_create_current_copy(adev->dm.dc);
if (!context) {
kfree(dm_state);
return ERR_PTR(-ENOMEM);
}
__drm_atomic_helper_private_obj_create_state(obj, &dm_state->base);
dm_state->context = context;
return &dm_state->base;
}
```
This is well-structured with proper error cleanup if `dc_state_create_current_copy()` fails.
**Issue: Missing return value check.** The call to `drm_atomic_private_obj_init()` now passes `NULL` as the state, which means it will internally call `atomic_create_state` — which can fail (returning `ERR_PTR(-ENOMEM)`). The return value is not checked:
```c
drm_atomic_private_obj_init(adev_to_drm(adev),
&adev->dm.atomic_obj,
NULL,
&dm_atomic_state_funcs);
```
This should be something like:
```c
ret = drm_atomic_private_obj_init(adev_to_drm(adev),
&adev->dm.atomic_obj,
NULL,
&dm_atomic_state_funcs);
if (ret)
return ret;
```
**Positive note**: The error path simplification is a nice side-effect. The old code was arguably buggy — it manually freed state on error after `drm_atomic_private_obj_init()` had already registered the object, which could lead to a use-after-free if cleanup later called `drm_atomic_private_obj_fini()`. The new code avoids that class of bug.
**Minor note (pre-existing)**: `dm_atomic_state_funcs` is not `const`, unlike the omap and tegra equivalents. Not introduced by this patch.
---
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-02-27 5:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 16:10 [PATCH v5 0/4] drm/atomic: Allocate drm_private_state through a callback Maxime Ripard
2026-02-24 16:10 ` [PATCH v5 1/4] drm/amdgpu: Switch private_obj initialization to atomic_create_state Maxime Ripard
2026-02-27 5:05 ` Claude Code Review Bot [this message]
2026-02-24 16:10 ` [PATCH v5 2/4] drm/omapdrm: " Maxime Ripard
2026-02-27 5:05 ` Claude review: " Claude Code Review Bot
2026-02-24 16:10 ` [PATCH v5 3/4] drm/tegra: " Maxime Ripard
2026-02-27 5:05 ` Claude review: " Claude Code Review Bot
2026-02-24 16:10 ` [PATCH v5 4/4] drm/atomic: Remove state argument to drm_atomic_private_obj_init Maxime Ripard
2026-02-27 5:05 ` Claude review: " Claude Code Review Bot
2026-02-27 5:05 ` Claude review: drm/atomic: Allocate drm_private_state through a callback 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-patch1-20260224-drm-private-obj-reset-v5-1-5a72f8ec9934@kernel.org \
--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