From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/amdgpu/amdgpu_connectors: remove amdgpu_connector_free_edid
Date: Fri, 13 Feb 2026 16:24:45 +1000 [thread overview]
Message-ID: <review-patch2-20260212222029.15777-3-jpeisach@ubuntu.com> (raw)
In-Reply-To: <20260212222029.15777-3-jpeisach@ubuntu.com>
Patch Review
This patch removes the wrapper function and calls `drm_edid_free()` directly at all call sites. While this seems like a straightforward cleanup, it introduces a critical resource management bug.
> @@ -297,14 +297,6 @@ static void amdgpu_connector_get_edid(struct drm_connector *connector)
> }
> }
>
> -static void amdgpu_connector_free_edid(struct drm_connector *connector)
> -{
> - struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
> -
> - kfree(amdgpu_connector->edid);
> - amdgpu_connector->edid = NULL;
> -}
The removed function performs two critical operations: freeing the EDID and setting the pointer to NULL. The replacement code below only does the first operation.
> @@ -873,7 +865,7 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)
> if (dret) {
> amdgpu_connector->detected_by_load = false;
> - amdgpu_connector_free_edid(connector);
> + drm_edid_free(amdgpu_connector->edid);
> amdgpu_connector_get_edid(connector);
This is the first problematic location. After freeing `amdgpu_connector->edid`, the pointer is not set to NULL. Then `amdgpu_connector_get_edid()` is called. Looking at line 261 of that function:
```c
if (amdgpu_connector->edid)
return;
```
This early-return check now sees a dangling pointer instead of NULL, so the function returns immediately without fetching new EDID data. This breaks the intended behavior of refreshing the EDID after freeing the old one. The same issue appears at lines 1048-1049 in the DVI detect function.
> @@ -883,7 +881,7 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)
> */
> if (amdgpu_connector->use_digital && amdgpu_connector->shared_ddc) {
> - amdgpu_connector_free_edid(connector);
> + drm_edid_free(amdgpu_connector->edid);
> ret = connector_status_disconnected;
> } else {
> ret = connector_status_connected;
After freeing the EDID here, if the code path later reaches `amdgpu_connector_destroy()` (line 749) or returns through another path that accesses `amdgpu_connector->edid`, you'll have use-after-free or double-free bugs. The same issue occurs at lines 1064, 979, and 1412.
The fix is straightforward: after each `drm_edid_free(amdgpu_connector->edid)` call, add `amdgpu_connector->edid = NULL;`. Alternatively, create a helper function that does both operations atomically, or modify the locations to use a pattern like:
```c
const struct drm_edid *old_edid = amdgpu_connector->edid;
amdgpu_connector->edid = NULL;
drm_edid_free(old_edid);
```
The only location where setting NULL is not needed is in `amdgpu_connector_destroy()` (line 749) since the entire connector structure is being freed immediately after.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-02-13 6:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 22:20 [PATCH 0/2] drm/amdgpu/amdgpu_connectors: Use struct drm_edid Joshua Peisach
2026-02-12 22:20 ` [PATCH 1/2] drm/amdgpu/amdgpu_connectors: use struct drm_edid instead of struct edid Joshua Peisach
2026-02-13 6:24 ` Claude review: " Claude Code Review Bot
2026-02-12 22:20 ` [PATCH 2/2] drm/amdgpu/amdgpu_connectors: remove amdgpu_connector_free_edid Joshua Peisach
2026-02-13 6:24 ` Claude Code Review Bot [this message]
2026-02-13 6:18 ` Claude review: drm/amdgpu/amdgpu_connectors: Use struct drm_edid 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-patch2-20260212222029.15777-3-jpeisach@ubuntu.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