OSDN Git Service

drm/virtio: Fix cache entry creation race.
authorDavid Riley <davidriley@chromium.org>
Wed, 5 Jun 2019 23:44:22 +0000 (16:44 -0700)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 6 Jun 2019 07:44:40 +0000 (09:44 +0200)
commit5934ce998faf33277cc19522609577be835e80b1
treec5fd01c9eca7b8521fd0c3c880e97dc2edc32204
parent676a905b09d533ab3a30da753dba4f2daee97402
drm/virtio: Fix cache entry creation race.

virtio_gpu_cmd_get_capset would check for the existence of an entry
under lock.  If it was not found, it would unlock and call
virtio_gpu_cmd_get_capset to create a new entry.  The new entry would
be added it to the list without checking if it was added by another
task during the period where the lock was not held resulting in
duplicate entries.

Compounding this issue, virtio_gpu_cmd_capset_cb would stop iterating
after find the first matching entry.  Multiple callbacks would modify
the first entry, but any subsequent entries and their associated waiters
would eventually timeout since they don't become valid, also wasting
memory along the way.

Signed-off-by: David Riley <davidriley@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20190605234423.11348-3-davidriley@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
drivers/gpu/drm/virtio/virtgpu_vq.c