Commit 436c0c18 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

virtio: check F_CONFIG feature before sending GET/SET_CONFIG



The device might not have this message implemented.
Sending it could result in a connection being terminated.

Change-Id: I53c08f1108ebc7de630569f3983c317cc6510fa4
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/417636


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 62844ae3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -222,6 +222,10 @@ virtio_user_read_dev_config(struct virtio_dev *vdev, size_t offset,
	struct virtio_user_dev *dev = vdev->ctx;
	struct vhost_user_config cfg = {0};

	if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_CONFIG)) == 0) {
		return -ENOTSUP;
	}

	cfg.offset = 0;
	cfg.size = VHOST_USER_MAX_CONFIG_SIZE;

@@ -241,6 +245,10 @@ virtio_user_write_dev_config(struct virtio_dev *vdev, size_t offset,
	struct virtio_user_dev *dev = vdev->ctx;
	struct vhost_user_config cfg = {0};

	if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_CONFIG)) == 0) {
		return -ENOTSUP;
	}

	cfg.offset = offset;
	cfg.size = length;
	memcpy(cfg.region, src, length);