Commit a00b6819 authored by Ben Walker's avatar Ben Walker Committed by Daniel Verkamp
Browse files

bdev/virtio: Abort on bad index in virtio_dev_queue_get_thread



There is no way to recover from this.

Change-Id: I1667b032bab867d58ad23fa8b1bd59f81620b442
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/408246


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 7540c61a
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -613,20 +613,16 @@ virtio_dev_find_and_acquire_queue(struct virtio_dev *vdev, uint16_t start_index)
struct spdk_thread *
virtio_dev_queue_get_thread(struct virtio_dev *vdev, uint16_t index)
{
	struct virtqueue *vq;
	struct spdk_thread *thread = NULL;

	if (index >= vdev->max_queues) {
		SPDK_ERRLOG("given vq index %"PRIu16" exceeds max queue count %"PRIu16"\n",
			    index, vdev->max_queues);
		return NULL;
		abort(); /* This is not recoverable */
	}

	pthread_mutex_lock(&vdev->mutex);
	vq = vdev->vqs[index];
	if (vq != NULL) {
		thread = vq->owner_thread;
	}
	thread = vdev->vqs[index]->owner_thread;
	pthread_mutex_unlock(&vdev->mutex);

	return thread;