public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/gem: Remove unneeded ret check in change handle ioctl
Date: Sat, 16 May 2026 15:11:29 +1000	[thread overview]
Message-ID: <review-patch1-20260511142540.2989187-1-jonathan.cavitt@intel.com> (raw)
In-Reply-To: <20260511142540.2989187-1-jonathan.cavitt@intel.com>

Patch Review

**Base mismatch — patch is obsolete.**

The patch removes these lines (from its base revision `abc8e41d6652`):

```c
	spin_unlock(&file_priv->table_lock);

-	if (ret < 0)
-		goto out_unlock;
-
	if (obj->dma_buf) {
```

The commit message states this `if (ret < 0)` check after `idr_replace` is dead code because "in the only place we modify the return value between there and the previous return value check, we also immediately jump to out_unlock, bypassing the check entirely." For an `idr_replace`-based implementation, this analysis is likely correct — `idr_replace` returns `void *` (not `int`), so any error from it would be caught via `IS_ERR()` and would immediately `goto out_unlock`, meaning `ret` is never set to a negative value in a path that falls through to this check.

**However, the current drm-next code at `drivers/gpu/drm/drm_gem.c:1044-1050` has been rewritten:**

```c
	spin_lock(&file_priv->table_lock);
	ret = idr_alloc(&file_priv->object_idr, obj, handle, handle + 1,
			GFP_NOWAIT);
	spin_unlock(&file_priv->table_lock);

	if (ret < 0)
		goto out_unlock;
```

In the current code, `ret` is set directly by `idr_alloc()`, which returns a negative errno on failure (e.g., `-ENOSPC` if the handle is already in use, `-ENOMEM`). The `if (ret < 0)` check is **not dead code** — it is essential for error handling. Removing it in the current code would cause the function to proceed with a failed allocation, leading to incorrect behavior.

**Issues:**
1. The patch does not apply — the pre-image hash `abc8e41d6652` does not match the current drm-next tree.
2. The commit message references `idr_replace`, but drm-next uses `idr_alloc` — the function has been refactored since the patch was written.
3. Naively adapting this patch to the current code would introduce a bug by removing a necessary error check on `idr_alloc`'s return value.

**Verdict:** The underlying dead-code observation was probably valid for the `idr_replace` version, but the code has moved on. This patch should be dropped. If the author rebases onto drm-next, they will find the `idr_replace` call is gone and the analogous `ret` check is no longer dead.

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-05-16  5:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 14:25 [PATCH] drm/gem: Remove unneeded ret check in change handle ioctl Jonathan Cavitt
2026-05-14 15:16 ` Rodrigo Vivi
2026-05-14 15:23   ` Rodrigo Vivi
2026-05-16  5:11 ` Claude review: " Claude Code Review Bot
2026-05-16  5:11 ` 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-20260511142540.2989187-1-jonathan.cavitt@intel.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