mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 20:32:04 +09:00
UPSTREAM: drm/virtio: fix resource id creation race
commitfbb30168c7upstream. 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:16065fcdd1("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> (cherry picked from commit9998ebb5e7) Bug: 153580313 Signed-off-by: Alistair Delva <adelva@google.com> Change-Id: Iad0ca447e5be8b8098962b50e8d38356d1024126
This commit is contained in:
committed by
Alistair Delva
parent
380c5c0d07
commit
2236a7f126
@@ -42,8 +42,8 @@ static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
|
||||
* "f91a9dd35715 Fix unlinking resources from hash
|
||||
* table." (Feb 2019) fixes the bug.
|
||||
*/
|
||||
static int handle;
|
||||
handle++;
|
||||
static atomic_t seqno = ATOMIC_INIT(0);
|
||||
int handle = atomic_inc_return(&seqno);
|
||||
*resid = handle + 1;
|
||||
} else {
|
||||
int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
|
||||
|
||||
Reference in New Issue
Block a user