Skip to content

Commit 64ffa39

Browse files
committed
virtio_net: use LE accessors for speed/duplex
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 <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 83eb9db commit 64ffa39

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

drivers/net/virtio_net.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,12 +2264,13 @@ static void virtnet_update_settings(struct virtnet_info *vi)
22642264
if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_SPEED_DUPLEX))
22652265
return;
22662266

2267-
speed = virtio_cread32(vi->vdev, offsetof(struct virtio_net_config,
2268-
speed));
2267+
virtio_cread_le(vi->vdev, struct virtio_net_config, speed, &speed);
2268+
22692269
if (ethtool_validate_speed(speed))
22702270
vi->speed = speed;
2271-
duplex = virtio_cread8(vi->vdev, offsetof(struct virtio_net_config,
2272-
duplex));
2271+
2272+
virtio_cread_le(vi->vdev, struct virtio_net_config, duplex, &duplex);
2273+
22732274
if (ethtool_validate_duplex(duplex))
22742275
vi->duplex = duplex;
22752276
}

include/uapi/linux/virtio_net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct virtio_net_config {
9999
* speed, in units of 1Mb. All values 0 to INT_MAX are legal.
100100
* Any other value stands for unknown.
101101
*/
102-
__virtio32 speed;
102+
__le32 speed;
103103
/*
104104
* 0x00 - half duplex
105105
* 0x01 - full duplex

0 commit comments

Comments
 (0)