Re: [PATCH 03/10] drm/virtio: fix lock context imbalance
On 2016年12月06日 23:40, Michael S. Tsirkin wrote: When virtio_gpu_free_vbufs exits due to list empty, it does not drop the free_vbufs lock that it took. list empty is not expected to happen anyway, but it can't hurt to fix this and drop the lock. Signed-off-by: Michael S. Tsirkin--- drivers/gpu/drm/virtio/virtgpu_vq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Jason Wang diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 5a0f8a7..2f0c2f9 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -109,8 +109,10 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev) spin_lock(>free_vbufs_lock); for (i = 0; i < count; i++) { - if (WARN_ON(list_empty(>free_vbufs))) + if (WARN_ON(list_empty(>free_vbufs))) { + spin_unlock(>free_vbufs_lock); return; + } vbuf = list_first_entry(>free_vbufs, struct virtio_gpu_vbuffer, list); list_del(>list);
Re: [PATCH 03/10] drm/virtio: fix lock context imbalance
On 2016年12月06日 23:40, Michael S. Tsirkin wrote: When virtio_gpu_free_vbufs exits due to list empty, it does not drop the free_vbufs lock that it took. list empty is not expected to happen anyway, but it can't hurt to fix this and drop the lock. Signed-off-by: Michael S. Tsirkin --- drivers/gpu/drm/virtio/virtgpu_vq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Jason Wang diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 5a0f8a7..2f0c2f9 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -109,8 +109,10 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev) spin_lock(>free_vbufs_lock); for (i = 0; i < count; i++) { - if (WARN_ON(list_empty(>free_vbufs))) + if (WARN_ON(list_empty(>free_vbufs))) { + spin_unlock(>free_vbufs_lock); return; + } vbuf = list_first_entry(>free_vbufs, struct virtio_gpu_vbuffer, list); list_del(>list);
[PATCH 03/10] drm/virtio: fix lock context imbalance
When virtio_gpu_free_vbufs exits due to list empty, it does not drop the free_vbufs lock that it took. list empty is not expected to happen anyway, but it can't hurt to fix this and drop the lock. Signed-off-by: Michael S. Tsirkin--- drivers/gpu/drm/virtio/virtgpu_vq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 5a0f8a7..2f0c2f9 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -109,8 +109,10 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev) spin_lock(>free_vbufs_lock); for (i = 0; i < count; i++) { - if (WARN_ON(list_empty(>free_vbufs))) + if (WARN_ON(list_empty(>free_vbufs))) { + spin_unlock(>free_vbufs_lock); return; + } vbuf = list_first_entry(>free_vbufs, struct virtio_gpu_vbuffer, list); list_del(>list); -- MST
[PATCH 03/10] drm/virtio: fix lock context imbalance
When virtio_gpu_free_vbufs exits due to list empty, it does not drop the free_vbufs lock that it took. list empty is not expected to happen anyway, but it can't hurt to fix this and drop the lock. Signed-off-by: Michael S. Tsirkin --- drivers/gpu/drm/virtio/virtgpu_vq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 5a0f8a7..2f0c2f9 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -109,8 +109,10 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev) spin_lock(>free_vbufs_lock); for (i = 0; i < count; i++) { - if (WARN_ON(list_empty(>free_vbufs))) + if (WARN_ON(list_empty(>free_vbufs))) { + spin_unlock(>free_vbufs_lock); return; + } vbuf = list_first_entry(>free_vbufs, struct virtio_gpu_vbuffer, list); list_del(>list); -- MST