From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: gpu: host1x: Fix use-after-free in host1x_bo_clear_cached_mappings
Date: Thu, 04 Jun 2026 11:54:02 +1000 [thread overview]
Message-ID: <review-overall-20260603-host1x-bocache-leak-fix-v1-1-494101dbfd30@nvidia.com> (raw)
In-Reply-To: <20260603-host1x-bocache-leak-fix-v1-1-494101dbfd30@nvidia.com>
Overall Series Review
Subject: gpu: host1x: Fix use-after-free in host1x_bo_clear_cached_mappings
Author: Mikko Perttunen <mperttunen@nvidia.com>
Patches: 1
Reviewed: 2026-06-04T11:54:02.847182
---
This is a single-patch fix for a use-after-free bug in `host1x_bo_clear_cached_mappings()`. The bug was introduced by a prerequisite commit ("gpu: host1x: Allow entries in BO caches to be freed") and was reported by Dan Carpenter (likely via static analysis / Smatch).
The fix is correct, minimal, and obviously right. The `cache` local variable is assigned from `mapping->cache` at the top of the loop iteration (line 1011), and is used for the NULL check immediately after. However, the `mutex_lock`/`mutex_unlock` calls then redundantly dereference `mapping->cache` instead of using the already-saved `cache` local. Since `__host1x_bo_unpin()` drops the last kref, and the `unpin` callback (e.g. `tegra_bo_unpin()`) calls `kfree(map)`, the `mapping` pointer is freed by the time `mutex_unlock(&mapping->cache->lock)` executes — a clear use-after-free.
**Verdict: Patch looks good. Recommend applying.**
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-06-04 1:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 8:37 [PATCH] gpu: host1x: Fix use-after-free in host1x_bo_clear_cached_mappings Mikko Perttunen
2026-06-04 1:54 ` Claude Code Review Bot [this message]
2026-06-04 1:54 ` Claude review: " 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-20260603-host1x-bocache-leak-fix-v1-1-494101dbfd30@nvidia.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