bc04ed
From 77d54985b85a0cb760330ec2bd92505e0a2a97a9 Mon Sep 17 00:00:00 2001
bc04ed
From: Prasad J Pandit <pjp@fedoraproject.org>
bc04ed
Date: Tue, 29 Nov 2016 00:38:39 +0530
bc04ed
Subject: [PATCH] net: mcf: check receive buffer size register value
bc04ed
bc04ed
ColdFire Fast Ethernet Controller uses a receive buffer size
bc04ed
register(EMRBR) to hold maximum size of all receive buffers.
bc04ed
It is set by a user before any operation. If it was set to be
bc04ed
zero, ColdFire emulator would go into an infinite loop while
bc04ed
receiving data in mcf_fec_receive. Add check to avoid it.
bc04ed
bc04ed
Reported-by: Wjjzhang <wjjzhang@tencent.com>
bc04ed
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
bc04ed
Signed-off-by: Jason Wang <jasowang@redhat.com>
bc04ed
---
bc04ed
 hw/net/mcf_fec.c |    2 +-
bc04ed
 1 files changed, 1 insertions(+), 1 deletions(-)
bc04ed
bc04ed
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
bc04ed
index dc61bac..4025eb3 100644
bc04ed
--- a/hw/mcf_fec.c
bc04ed
+++ b/hw/mcf_fec.c
bc04ed
@@ -393,7 +393,7 @@ static void mcf_fec_write(void *opaque, hwaddr addr,
bc04ed
         s->tx_descriptor = s->etdsr;
bc04ed
         break;
bc04ed
     case 0x188:
bc04ed
-        s->emrbr = value & 0x7f0;
bc04ed
+        s->emrbr = value > 0 ? value & 0x7F0 : 0x7F0;
bc04ed
         break;
bc04ed
     default:
bc04ed
         cpu_abort(cpu_single_env, "mcf_fec_write Bad address 0x%x\n",
bc04ed
-- 
bc04ed
1.7.0.4
bc04ed