Skip to content

Commit

Permalink
virtio_net: use LE accessors for speed/duplex
Browse files Browse the repository at this point in the history
Speed and duplex config fields depend on VIRTIO_NET_F_SPEED_DUPLEX
which being 63>31 depends on VIRTIO_F_VERSION_1.

Accordingly, use LE accessors for these fields.

Reported-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
mstsirkin committed Aug 5, 2020
1 parent 83eb9db commit 64ffa39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -2264,12 +2264,13 @@ static void virtnet_update_settings(struct virtnet_info *vi)
if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_SPEED_DUPLEX))
return;

speed = virtio_cread32(vi->vdev, offsetof(struct virtio_net_config,
speed));
virtio_cread_le(vi->vdev, struct virtio_net_config, speed, &speed);

if (ethtool_validate_speed(speed))
vi->speed = speed;
duplex = virtio_cread8(vi->vdev, offsetof(struct virtio_net_config,
duplex));

virtio_cread_le(vi->vdev, struct virtio_net_config, duplex, &duplex);

if (ethtool_validate_duplex(duplex))
vi->duplex = duplex;
}
Expand Down
2 changes: 1 addition & 1 deletion include/uapi/linux/virtio_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct virtio_net_config {
* speed, in units of 1Mb. All values 0 to INT_MAX are legal.
* Any other value stands for unknown.
*/
__virtio32 speed;
__le32 speed;
/*
* 0x00 - half duplex
* 0x01 - full duplex
Expand Down

0 comments on commit 64ffa39

Please sign in to comment.