drm/panfrost: Fix a race in panfrost_ioctl_madvise()
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 29 Nov 2019 13:59:02 +0000 (14:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Dec 2019 10:04:49 +0000 (11:04 +0100)
commit1ecf1946856224ebde8078a94bebba95222456b3
tree0f01d4fda0dac4e0a880fe8e5eba980a6b560d40
parentc902404d5013e57dbe08be0b8b36dffb08c6f46e
drm/panfrost: Fix a race in panfrost_ioctl_madvise()

commit 70cc77952efebf6722d483cb83cfb563ac9768db upstream.

If 2 threads change the MADVISE property of the same BO in parallel we
might end up with an shmem->madv value that's inconsistent with the
presence of the BO in the shrinker list.

The easiest solution to fix that is to protect the
drm_gem_shmem_madvise() call with the shrinker lock.

Fixes: 013b65101315 ("drm/panfrost: Add madvise and shrinker support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191129135908.2439529-3-boris.brezillon@collabora.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/panfrost/panfrost_drv.c