From patchwork Tue Dec 6 02:32:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 702986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tXm0V6J2Fz9sdn for ; Tue, 6 Dec 2016 13:34:02 +1100 (AEDT) Received: from localhost ([::1]:45679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cE5Zv-0004sZ-CG for incoming@patchwork.ozlabs.org; Mon, 05 Dec 2016 21:33:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cE5Yi-00046b-Fz for qemu-devel@nongnu.org; Mon, 05 Dec 2016 21:32:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cE5Yf-0006am-Te for qemu-devel@nongnu.org; Mon, 05 Dec 2016 21:32:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cE5Yf-0006aV-O7 for qemu-devel@nongnu.org; Mon, 05 Dec 2016 21:32:41 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9F2461B8C; Tue, 6 Dec 2016 02:32:40 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (vpn1-4-169.pek2.redhat.com [10.72.4.169]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uB62WY5C025428; Mon, 5 Dec 2016 21:32:38 -0500 From: Jason Wang To: peter.maydell@linaro.org, stefanha@redhat.com, qemu-devel@nongnu.org Date: Tue, 6 Dec 2016 10:32:30 +0800 Message-Id: <1480991552-14360-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1480991552-14360-1-git-send-email-jasowang@redhat.com> References: <1480991552-14360-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 06 Dec 2016 02:32:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL V2 1/3] net: mcf: check receive buffer size register value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Prasad J Pandit Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Prasad J Pandit ColdFire Fast Ethernet Controller uses a receive buffer size register(EMRBR) to hold maximum size of all receive buffers. It is set by a user before any operation. If it was set to be zero, ColdFire emulator would go into an infinite loop while receiving data in mcf_fec_receive. Add check to avoid it. Reported-by: Wjjzhang Signed-off-by: Prasad J Pandit Signed-off-by: Jason Wang --- hw/net/mcf_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c index dc61bac..4025eb3 100644 --- a/hw/net/mcf_fec.c +++ b/hw/net/mcf_fec.c @@ -393,7 +393,7 @@ static void mcf_fec_write(void *opaque, hwaddr addr, s->tx_descriptor = s->etdsr; break; case 0x188: - s->emrbr = value & 0x7f0; + s->emrbr = value > 0 ? value & 0x7F0 : 0x7F0; break; default: hw_error("mcf_fec_write Bad address 0x%x\n", (int)addr);