qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-serial-bus: use correct lengths in control_out() message
@ 2012-03-11 13:52 Michael Tokarev
  2012-03-12  8:59 ` Amit Shah
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Tokarev @ 2012-03-11 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

In case of more than one control message, the code will use
size of the largest message so far for all subsequent messages,
instead of using size of current one.  Fix it.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/virtio-serial-bus.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index e22940e..abe48ec 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -451,28 +451,28 @@ static void control_out(VirtIODevice *vdev, VirtQueue *vq)
 
     vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
 
     len = 0;
     buf = NULL;
     while (virtqueue_pop(vq, &elem)) {
-        size_t cur_len, copied;
+        size_t cur_len;
 
         cur_len = iov_size(elem.out_sg, elem.out_num);
         /*
          * Allocate a new buf only if we didn't have one previously or
          * if the size of the buf differs
          */
         if (cur_len > len) {
             g_free(buf);
 
             buf = g_malloc(cur_len);
             len = cur_len;
         }
-        copied = iov_to_buf(elem.out_sg, elem.out_num, buf, 0, len);
+        iov_to_buf(elem.out_sg, elem.out_num, buf, 0, cur_len);
 
-        handle_control_message(vser, buf, copied);
+        handle_control_message(vser, buf, cur_len);
         virtqueue_push(vq, &elem, 0);
     }
     g_free(buf);
     virtio_notify(vdev, vq);
 }
 
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-03-13 14:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-11 13:52 [Qemu-devel] [PATCH] virtio-serial-bus: use correct lengths in control_out() message Michael Tokarev
2012-03-12  8:59 ` Amit Shah
2012-03-12  9:22   ` Michael Tokarev
2012-03-12 11:06     ` Amit Shah
2012-03-12 11:44       ` Michael Tokarev
2012-03-13 14:01         ` Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).