Commit dd717762 authored by Dmitry Osipenko's avatar Dmitry Osipenko
Browse files

drm/shmem-helper: Fix unsetting shmem vaddr while vmap refcount > 0



We switched to use refcount_t for vmaps and missed to change the vunmap
code to properly unset the vmap pointer, which is now cleared while vmap's
refcount > 0. Clear the cached vmap pointer only when refcounting drops to
zero to fix the bug.

Fixes: e1fc39a9 ("drm/shmem-helper: Use refcount_t for vmap_use_count")
Reported-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Closes: https://lore.kernel.org/dri-devel/20250403105053.788b0f6e@collabora.com/T/#m3dca6d81bedc8d6146a56b82694624fbc6fa4c96


Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Tested-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250403142633.484660-1-dmitry.osipenko@collabora.com
parent 446d3855
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -415,11 +415,11 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,

		if (refcount_dec_and_test(&shmem->vmap_use_count)) {
			vunmap(shmem->vaddr);
			shmem->vaddr = NULL;

			drm_gem_shmem_unpin_locked(shmem);
		}
	}

	shmem->vaddr = NULL;
}
EXPORT_SYMBOL_GPL(drm_gem_shmem_vunmap_locked);