From: Dan Carpenter <error27@gmail.com>
To: Mikko Perttunen <mperttunen@nvidia.com>
Cc: linux-tegra@vger.kernel.org
Subject: [bug report] gpu: host1x: Allow entries in BO caches to be freed
Date: Tue, 2 Jun 2026 10:22:20 +0300 [thread overview]
Message-ID: <ah6ErK6f4kVudVIA@stanley.mountain> (raw)
Hello Mikko Perttunen,
Commit 3cbf5e3c46e6 ("gpu: host1x: Allow entries in BO caches to be
freed") from May 15, 2026 (linux-next), leads to the following Smatch
static checker warning:
drivers/gpu/host1x/bus.c:1018 host1x_bo_clear_cached_mappings()
warn: 'mapping' was already freed. (line 1017)
drivers/gpu/host1x/bus.c
1008 struct host1x_bo_cache *cache;
1009
1010 list_for_each_entry_safe(mapping, tmp, &bo->mappings, list) {
^^^^^
We have to use _safe() here because mapping is freed.
1011 cache = mapping->cache;
1012 if (WARN_ON(!cache))
1013 continue;
1014
1015 mutex_lock(&mapping->cache->lock);
1016 WARN_ON(kref_read(&mapping->ref) != 1);
1017 __host1x_bo_unpin(&mapping->ref);
^^^^^^^^^^^^^
This frees mapping.
--> 1018 mutex_unlock(&mapping->cache->lock);
^^^^^^^
Use after free.
1019 }
1020 }
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
reply other threads:[~2026-06-02 7:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=ah6ErK6f4kVudVIA@stanley.mountain \
--to=error27@gmail.com \
--cc=linux-tegra@vger.kernel.org \
--cc=mperttunen@nvidia.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