diff mbox

net: mcf: check buffer descriptor length

Message ID 1474465547-31638-1-git-send-email-ppandit@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Prasad Pandit Sept. 21, 2016, 1:45 p.m. UTC
From: Prasad J Pandit <pjp@fedoraproject.org>

ColdFire Fast Ethernet Controller uses buffer descriptors to manage
data flow to/fro receive & transmit queues. While transmitting
packets, it could continue to read buffer descriptors if a buffer
descriptor has length of zero. Add check to avoid it.

Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/net/mcf_fec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 7c0398e..f193e15 100644
--- a/hw/net/mcf_fec.c
+++ b/hw/net/mcf_fec.c
@@ -161,7 +161,7 @@  static void mcf_fec_do_tx(mcf_fec_state *s)
         mcf_fec_read_bd(&bd, addr);
         DPRINTF("tx_bd %x flags %04x len %d data %08x\n",
                 addr, bd.flags, bd.length, bd.data);
-        if ((bd.flags & FEC_BD_R) == 0) {
+        if (!bd.length || (bd.flags & FEC_BD_R) == 0) {
             /* Run out of descriptors to transmit.  */
             break;
         }