Blame 0010-net-mcf-limit-buffer-descriptor-count.patch

3a13dd
From: Prasad J Pandit <pjp@fedoraproject.org>
3a13dd
Date: Thu, 22 Sep 2016 16:02:37 +0530
3a13dd
Subject: [PATCH] net: mcf: limit buffer descriptor count
3a13dd
3a13dd
ColdFire Fast Ethernet Controller uses buffer descriptors to manage
3a13dd
data flow to/fro receive & transmit queues. While transmitting
3a13dd
packets, it could continue to read buffer descriptors if a buffer
3a13dd
descriptor has length of zero and has crafted values in bd.flags.
3a13dd
Set upper limit to number of buffer descriptors.
3a13dd
3a13dd
Reported-by: Li Qiang <liqiang6-s@360.cn>
3a13dd
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
3a13dd
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
3a13dd
Signed-off-by: Jason Wang <jasowang@redhat.com>
3a13dd
(cherry picked from commit 070c4b92b8cd5390889716677a0b92444d6e087a)
3a13dd
---
3a13dd
 hw/net/mcf_fec.c | 5 +++--
3a13dd
 1 file changed, 3 insertions(+), 2 deletions(-)
3a13dd
3a13dd
diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
3a13dd
index 0ee8ad9..d31fea1 100644
3a13dd
--- a/hw/net/mcf_fec.c
3a13dd
+++ b/hw/net/mcf_fec.c
3a13dd
@@ -23,6 +23,7 @@ do { printf("mcf_fec: " fmt , ## __VA_ARGS__); } while (0)
3a13dd
 #define DPRINTF(fmt, ...) do {} while(0)
3a13dd
 #endif
3a13dd
 
3a13dd
+#define FEC_MAX_DESC 1024
3a13dd
 #define FEC_MAX_FRAME_SIZE 2032
3a13dd
 
3a13dd
 typedef struct {
3a13dd
@@ -149,7 +150,7 @@ static void mcf_fec_do_tx(mcf_fec_state *s)
3a13dd
     uint32_t addr;
3a13dd
     mcf_fec_bd bd;
3a13dd
     int frame_size;
3a13dd
-    int len;
3a13dd
+    int len, descnt = 0;
3a13dd
     uint8_t frame[FEC_MAX_FRAME_SIZE];
3a13dd
     uint8_t *ptr;
3a13dd
 
3a13dd
@@ -157,7 +158,7 @@ static void mcf_fec_do_tx(mcf_fec_state *s)
3a13dd
     ptr = frame;
3a13dd
     frame_size = 0;
3a13dd
     addr = s->tx_descriptor;
3a13dd
-    while (1) {
3a13dd
+    while (descnt++ < FEC_MAX_DESC) {
3a13dd
         mcf_fec_read_bd(&bd, addr);
3a13dd
         DPRINTF("tx_bd %x flags %04x len %d data %08x\n",
3a13dd
                 addr, bd.flags, bd.length, bd.data);