From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn1II-0007To-EX for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:31:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn1IF-00045x-8L for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:31:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn1IF-00045t-2e for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:31:51 -0400 From: P J P Date: Thu, 22 Sep 2016 16:01:38 +0530 Message-Id: <1474540298-4152-1-git-send-email-ppandit@redhat.com> Subject: [Qemu-devel] [PATCH v2] net: imx: limit buffer descriptor count List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu Developers Cc: Paolo Bonzini , Jason Wang , Li Qiang , Prasad J Pandit From: Prasad J Pandit i.MX 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 and has crafted values in bd.flags. Set an upper limit to number of buffer descriptors. Reported-by: Li Qiang Signed-off-by: Prasad J Pandit --- hw/net/imx_fec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Update per -> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index e60e338..547fa99 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -94,6 +94,8 @@ static const VMStateDescription vmstate_imx_fec = { #define PHY_INT_PARFAULT (1 << 2) #define PHY_INT_AUTONEG_PAGE (1 << 1) +#define IMX_MAX_DESC 1024 + static void imx_fec_update(IMXFECState *s); /* @@ -264,12 +266,12 @@ static void imx_fec_update(IMXFECState *s) static void imx_fec_do_tx(IMXFECState *s) { - int frame_size = 0; + int frame_size = 0, descnt = 0; uint8_t frame[FEC_MAX_FRAME_SIZE]; uint8_t *ptr = frame; uint32_t addr = s->tx_descriptor; - while (1) { + while (descnt++ < IMX_MAX_DESC) { IMXFECBufDesc bd; int len; -- 2.5.5