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/pagemap_util: Ensure proper cache lock management on free
Date: Sat, 21 Feb 2026 05:51:04 +1000	[thread overview]
Message-ID: <review-overall-20260220190943.66961-2-jonathan.cavitt@intel.com> (raw)
In-Reply-To: <20260220190943.66961-2-jonathan.cavitt@intel.com>

Overall Series Review

Subject: drm/pagemap_util: Ensure proper cache lock management on free
Author: Jonathan Cavitt <jonathan.cavitt@intel.com>
Patches: 1
Reviewed: 2026-02-21T05:51:04.385592

---

This is a single-patch submission fixing a spinlock leak in `drm_pagemap_cache_fini()` in the new `drm_pagemap_util.c` infrastructure. The bug is real: when `dpagemap` is non-NULL but `drm_pagemap_shrinker_cancel()` returns false (meaning the shrinker scan already dequeued the dpagemap), the original code falls through the `if` block without ever calling `spin_unlock(&cache->lock)`. This would cause a spinlock deadlock on any subsequent lock attempt and trigger lockdep warnings.

The fix is correct but uses an unusual control flow pattern — placing the `out:` label inside an `else` block and jumping into it with `goto`. While this is legal C, it results in code that is harder to read than necessary for a two-path function. A straightforward alternative would be to simply add `spin_unlock(&cache->lock)` in the else branch without reusing the `out:` label, or to restructure the function to unlock unconditionally before the conditional destroy.

The commit message undersells the issue. It says the lock is "probably unnecessary given the cache is being freed" and frames it as a consistency fix for static analysis. But the spinlock leak is a genuine bug: if the path is reached, `spin_unlock` is never called, and the subsequent `kfree(cache)` frees a locked spinlock, which will trigger `CONFIG_DEBUG_LOCK_ALLOC` warnings. The path *is* reachable — the shrinker scan can race with cache teardown, removing the dpagemap from the shrink list and making `drm_pagemap_shrinker_cancel()` return false while `cache->dpagemap` is still non-NULL.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-02-20 19:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20 19:09 [PATCH] drm/pagemap_util: Ensure proper cache lock management on free Jonathan Cavitt
2026-02-20 19:51 ` Claude Code Review Bot [this message]
2026-02-20 19:51 ` Claude review: " Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-02-24 15:48 [PATCH v2] " Jonathan Cavitt
2026-02-27  5:07 ` Claude review: " Claude Code Review Bot
2026-02-27  5:07 ` Claude Code Review Bot
2026-03-06 15:43 [PATCH v3] " Jonathan Cavitt
2026-03-08 22:43 ` Claude review: " Claude Code Review Bot
2026-03-08 22:43 ` 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-overall-20260220190943.66961-2-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