Commit d41ca5af authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

virtio: do not take address of packed members



The address of a packed member is not packed, which may cause accesses
to unaligned pointers.  Avoid this by reading the packed value before
passing it to another function.

Cc: Jason Wang <jasowang@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent b255df7e
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -667,9 +667,9 @@ static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)


    /* The config space (ignored on the far end in current versions) */
    /* The config space (ignored on the far end in current versions) */
    get_config(vdev, (uint8_t *)&config);
    get_config(vdev, (uint8_t *)&config);
    qemu_put_be16s(f, &config.cols);
    qemu_put_be16(f, config.cols);
    qemu_put_be16s(f, &config.rows);
    qemu_put_be16(f, config.rows);
    qemu_put_be32s(f, &config.max_nr_ports);
    qemu_put_be32(f, config.max_nr_ports);


    /* The ports map */
    /* The ports map */
    max_nr_ports = s->serial.max_virtserial_ports;
    max_nr_ports = s->serial.max_virtserial_ports;