Skip to content

Commit

Permalink
virtio_balloon: fix up endian-ness for free cmd id
Browse files Browse the repository at this point in the history
free cmd id is read using virtio endian, spec says all fields
in balloon are LE. Fix it up.

Fixes: 86a5597 ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
Cc: [email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
Acked-by: Jason Wang <[email protected]>
Reviewed-by: Wei Wang <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
  • Loading branch information
mstsirkin committed Jul 29, 2020
1 parent ca72cc3 commit 168c358
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/virtio/virtio_balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,14 @@ static int init_vqs(struct virtio_balloon *vb)
static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
{
if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
&vb->config_read_bitmap))
&vb->config_read_bitmap)) {
virtio_cread(vb->vdev, struct virtio_balloon_config,
free_page_hint_cmd_id,
&vb->cmd_id_received_cache);
/* Legacy balloon config space is LE, unlike all other devices. */
if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
}

return vb->cmd_id_received_cache;
}
Expand Down

0 comments on commit 168c358

Please sign in to comment.