Skip to content

Commit

Permalink
virtio_config: fix virtio_cread_bytes
Browse files Browse the repository at this point in the history
virtio_cread_bytes is implemented incorrectly in case length happens to
be 2,4 or 8 bytes: transports and devices will assume it's an integer
value that has to be converted to LE format.

Let's just do multiple 1-byte reads: this also makes life easier
for transports who only need to implement 1,2,4 and 8 byte reads.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Michael S. Tsirkin committed Dec 11, 2014
1 parent 30683a8 commit 3d26678
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/linux/virtio_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ static inline void virtio_cread_bytes(struct virtio_device *vdev,
unsigned int offset,
void *buf, size_t len)
{
vdev->config->get(vdev, offset, buf, len);
int i;

for (i = 0; i < len; i++)
vdev->config->get(vdev, offset + i, buf + i, 1);
}

static inline void virtio_cwrite8(struct virtio_device *vdev,
Expand Down

0 comments on commit 3d26678

Please sign in to comment.