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: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/417636 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
62844ae3ca
commit
436c0c189b
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user