Skip to content

Commit abeff53

Browse files
cyndisgregkh
authored andcommitted
gpu: host1x: Fix use-after-free in host1x_bo_clear_cached_mappings
[ Upstream commit 266cddf ] __host1x_bo_unpin() drops the last reference to the mapping and frees it, so we can't dereference mapping afterwards. The cache itself outlives the mapping, so use the cache local variable instead. Reported-by: Dan Carpenter <error27@gmail.com> Closes: https://lore.kernel.org/linux-tegra/ah6ErK6f4kVudVIA@stanley.mountain/T/#u Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://patch.msgid.link/20260603-host1x-bocache-leak-fix-v1-1-494101dbfd30@nvidia.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5592a20 commit abeff53

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/gpu/host1x/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,10 @@ void host1x_bo_clear_cached_mappings(struct host1x_bo *bo)
10061006
if (WARN_ON(!cache))
10071007
continue;
10081008

1009-
mutex_lock(&mapping->cache->lock);
1009+
mutex_lock(&cache->lock);
10101010
WARN_ON(kref_read(&mapping->ref) != 1);
10111011
__host1x_bo_unpin(&mapping->ref);
1012-
mutex_unlock(&mapping->cache->lock);
1012+
mutex_unlock(&cache->lock);
10131013
}
10141014
}
10151015
EXPORT_SYMBOL(host1x_bo_clear_cached_mappings);

0 commit comments

Comments
 (0)