]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
Musicpal: Fix descriptor walk in eth_send
authorJan Kiszka <jan.kiszka@web.de>
Sun, 24 Jan 2010 08:51:49 +0000 (09:51 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 26 Jan 2010 22:20:20 +0000 (16:20 -0600)
Commit 930c86820e introduced a regression to eth_send: eth_tx_desc_put
manipulates the host's tx descriptor copy before writing it back, but
two lines down the descriptor is evaluated again, leaving us with an
invalid next address if host and guest endianness differ. So this was
the actual issue commit 2e87c5b937 tried to paper over.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: malc <av1474@comtv.ru>
(cherry picked from commit 07b064e9de65a26a4cb36dfb37c7506ef17407fd)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/musicpal.c

index e424a7de395867af6d03fb0aecb30e6ee617e5f7..b8af15ed5bf4a68da3ecf2c95fd7e29ac079a27d 100644 (file)
@@ -238,14 +238,13 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index)
 {
     uint32_t desc_addr = s->tx_queue[queue_index];
     mv88w8618_tx_desc desc;
+    uint32_t next_desc;
     uint8_t buf[2048];
     int len;
 
-    if (!desc_addr) {
-        return;
-    }
     do {
         eth_tx_desc_get(desc_addr, &desc);
+        next_desc = desc.next;
         if (desc.cmdstat & MP_ETH_TX_OWN) {
             len = desc.bytes;
             if (len < 2048) {
@@ -256,7 +255,7 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index)
             s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
             eth_tx_desc_put(desc_addr, &desc);
         }
-        desc_addr = desc.next;
+        desc_addr = next_desc;
     } while (desc_addr != s->tx_queue[queue_index]);
 }