drm/virtio: fix resource id creation race
authorJohn Bates <jbates@chromium.org>
Thu, 20 Feb 2020 22:53:19 +0000 (14:53 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Mar 2020 12:00:24 +0000 (13:00 +0100)
commit9998ebb5e73c72ba11a025434be9c2ff1c33b1f0
tree29d85e626245b170b81b4600f6bc5267d5c1b55d
parentd41f6cfd9aa7c3f01b44fc1ee15bac5589fd1b60
drm/virtio: fix resource id creation race

commit fbb30168c7395b9cfeb9e6f7b0c0bca854a6552d upstream.

The previous code was not thread safe and caused
undefined behavior from spurious duplicate resource IDs.
In this patch, an atomic_t is used instead. We no longer
see any duplicate IDs in tests with this change.

Fixes: 16065fcdd19d ("drm/virtio: do NOT reuse resource ids")
Signed-off-by: John Bates <jbates@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20200220225319.45621-1-jbates@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/virtio/virtgpu_object.c