Skip to content

Commit cea6633

Browse files
mstsirkingregkh
authored andcommitted
virtio_balloon: fix up endian-ness for free cmd id
commit 168c358 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c2f787f commit cea6633

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/virtio/virtio_balloon.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,14 @@ static int init_vqs(struct virtio_balloon *vb)
529529
static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
530530
{
531531
if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
532-
&vb->config_read_bitmap))
532+
&vb->config_read_bitmap)) {
533533
virtio_cread(vb->vdev, struct virtio_balloon_config,
534534
free_page_report_cmd_id,
535535
&vb->cmd_id_received_cache);
536+
/* Legacy balloon config space is LE, unlike all other devices. */
537+
if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
538+
vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
539+
}
536540

537541
return vb->cmd_id_received_cache;
538542
}

0 commit comments

Comments
 (0)