public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/tegra: rgb: Fix use-after-free and leak in tegra_dc_rgb_probe()
@ 2026-04-07  8:46 Wentao Liang
  2026-04-12  3:58 ` Claude review: " Claude Code Review Bot
  2026-04-12  3:58 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-04-07  8:46 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Jonathan Hunter
  Cc: dri-devel, linux-tegra, linux-kernel, Wentao Liang, stable

Move the of_device_is_available() check before devm_add_action_or_reset()
to avoid using np after it may have been freed (if the action registration
fails). Also release np immediately when the device is not available to
prevent a reference leak.

Fixes: 3c3642335065 ("drm/tegra: rgb: Fix the unbound reference count")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/gpu/drm/tegra/rgb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index ff5a749710db..d7586fc820ce 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -215,13 +215,15 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
 	if (!np)
 		return -ENODEV;
 
+	if (!of_device_is_available(np)) {
+		of_node_put(np);
+		return -ENODEV;
+	}
+
 	err = devm_add_action_or_reset(dc->dev, tegra_dc_of_node_put, np);
 	if (err < 0)
 		return err;
 
-	if (!of_device_is_available(np))
-		return -ENODEV;
-
 	rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL);
 	if (!rgb)
 		return -ENOMEM;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Claude review: drm/tegra: rgb: Fix use-after-free and leak in tegra_dc_rgb_probe()
  2026-04-07  8:46 [PATCH] drm/tegra: rgb: Fix use-after-free and leak in tegra_dc_rgb_probe() Wentao Liang
  2026-04-12  3:58 ` Claude review: " Claude Code Review Bot
@ 2026-04-12  3:58 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-04-12  3:58 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/tegra: rgb: Fix use-after-free and leak in tegra_dc_rgb_probe()
Author: Wentao Liang <vulab@iscas.ac.cn>
Patches: 1
Reviewed: 2026-04-12T13:58:42.211186

---

This is a single patch claiming to fix a use-after-free and a reference leak in `tegra_dc_rgb_probe()`. **Both claimed bugs do not actually exist in the original code.** The patch itself is harmless — the resulting code is functionally equivalent — but the commit message is misleading, and this should not be tagged as a bug fix or backported to stable.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Claude review: drm/tegra: rgb: Fix use-after-free and leak in tegra_dc_rgb_probe()
  2026-04-07  8:46 [PATCH] drm/tegra: rgb: Fix use-after-free and leak in tegra_dc_rgb_probe() Wentao Liang
@ 2026-04-12  3:58 ` Claude Code Review Bot
  2026-04-12  3:58 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-04-12  3:58 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Claimed bug 1 — "use-after-free":** The commit message states the reorder avoids "using np after it may have been freed (if the action registration fails)." This is incorrect. In the original code:

```c
err = devm_add_action_or_reset(dc->dev, tegra_dc_of_node_put, np);
if (err < 0)
    return err;

if (!of_device_is_available(np))
    return -ENODEV;
```

If `devm_add_action_or_reset()` fails, the `_or_reset` part calls `tegra_dc_of_node_put(np)` (freeing `np`), and then `err < 0` causes an **immediate return**. The `of_device_is_available(np)` call is never reached. There is no use-after-free.

**Claimed bug 2 — "reference leak":** The commit message claims `np` leaks "when the device is not available." This is also incorrect. In the original code, when `of_device_is_available(np)` returns false, `tegra_dc_rgb_probe()` returns `-ENODEV`. The caller in `dc.c:3255` explicitly ignores `-ENODEV`:

```c
err = tegra_dc_rgb_probe(dc);
if (err < 0 && err != -ENODEV)
    return dev_err_probe(&pdev->dev, err, ...);
```

The overall device probe **succeeds**, so the devm action registered by `devm_add_action_or_reset()` remains active and will correctly call `of_node_put(np)` when the device is eventually removed. There is no leak.

**Assessment:** The patch is a **no-op from a correctness standpoint** — the reordering produces functionally equivalent behavior. The code after the patch is marginally tidier (avoids leaving a devm action registered for a node that won't be used), but this is a minor cleanup, not a bug fix. The `Fixes:` tag and `Cc: stable` are unwarranted.

**Recommendation:** NAK in its current form. If the author wants to submit this as a minor cleanup/style improvement without the `Fixes:` tag, `Cc: stable`, and the incorrect bug claims in the commit message, that would be a more honest framing — though even then, the value is marginal.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-12  3:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07  8:46 [PATCH] drm/tegra: rgb: Fix use-after-free and leak in tegra_dc_rgb_probe() Wentao Liang
2026-04-12  3:58 ` Claude review: " Claude Code Review Bot
2026-04-12  3:58 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox