]> git.baikalelectronics.ru Git - kernel.git/commit
drm/gem: Fix GEM handle release errors
authorJeffy Chen <jeffy.chen@rock-chips.com>
Fri, 19 Aug 2022 07:28:34 +0000 (15:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Sep 2022 10:04:53 +0000 (12:04 +0200)
commit6bd16b0f3ac06ff2da6966733d76e5bac75bc42a
tree38387fd397718e95c1540ce53e9138aa3d69e1b0
parente24af8a3ce0b42086a4d8367fce18f6fc76653c0
drm/gem: Fix GEM handle release errors

[ Upstream commit 4ea36b758a09f00ead28cc3d675cf728b588e111 ]

Currently we are assuming a one to one mapping between dmabuf and
GEM handle when releasing GEM handles.

But that is not always true, since we would create extra handles for the
GEM obj in cases like gem_open() and getfb{,2}().

A similar issue was reported at:
https://lore.kernel.org/all/20211105083308.392156-1-jay.xu@rock-chips.com/

Another problem is that the imported dmabuf might not always have
gem_obj->dma_buf set, which would cause leaks in
drm_gem_remove_prime_handles().

Let's fix these for now by using handle to find the exact map to remove.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220819072834.17888-1-jeffy.chen@rock-chips.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/drm_internal.h
drivers/gpu/drm/drm_prime.c