mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-21 23:16:50 +08:00
drm/pagemap_util: Ensure proper cache lock management on free
For the sake of consistency, ensure that the cache lock is always
unlocked after drm_pagemap_cache_fini. Spinlocks typically disable
preemption and if the code-path missing the unlock is hit, preemption
will remain disabled even if the lock is subsequently freed.
Fixes static analysis issue.
v2:
- Use requested code flow (Maarten)
v3:
- Clear cache->dpagemap (Matt Brost, Maarten)
v4:
- Reword commit message (Thomas)
Fixes: 77f14f2f2d ("drm/pagemap: Add a drm_pagemap cache and shrinker")
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Thomas Hellstrom <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patch.msgid.link/20260316151555.7553-2-jonathan.cavitt@intel.com
This commit is contained in:
committed by
Thomas Hellström
parent
74ef7844dd
commit
67253b28a6
@@ -65,18 +65,14 @@ static void drm_pagemap_cache_fini(void *arg)
|
||||
drm_dbg(cache->shrinker->drm, "Destroying dpagemap cache.\n");
|
||||
spin_lock(&cache->lock);
|
||||
dpagemap = cache->dpagemap;
|
||||
if (!dpagemap) {
|
||||
spin_unlock(&cache->lock);
|
||||
goto out;
|
||||
}
|
||||
cache->dpagemap = NULL;
|
||||
if (dpagemap && !drm_pagemap_shrinker_cancel(dpagemap))
|
||||
dpagemap = NULL;
|
||||
spin_unlock(&cache->lock);
|
||||
|
||||
if (drm_pagemap_shrinker_cancel(dpagemap)) {
|
||||
cache->dpagemap = NULL;
|
||||
spin_unlock(&cache->lock);
|
||||
if (dpagemap)
|
||||
drm_pagemap_destroy(dpagemap, false);
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_destroy(&cache->lookup_mutex);
|
||||
kfree(cache);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user