Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1916FC433EF for ; Tue, 19 Jul 2022 15:30:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 18F5B8407F; Tue, 19 Jul 2022 17:29:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.b="jHlho5BZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 025CF84052; Tue, 19 Jul 2022 10:48:01 +0200 (CEST) Received: from mail-m963.mail.126.com (mail-m963.mail.126.com [123.126.96.3]) by phobos.denx.de (Postfix) with ESMTP id CFB208403F for ; Tue, 19 Jul 2022 10:47:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mikeljx@126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=ylLUR 52yBLjpfk9kZrBJ6OA6jG5HUCtPm9Xy3VH3hsY=; b=jHlho5BZirmq6F/z124UE i7iTGQ1Qrwv5054YXBu4mk4YwFwZ0jHHS9DhNAKD4VpgdYGKbxf3NuiDsZqQHwEN yjWiWolrJ8++CKeUGlGs6r/gxxgn9LCAzOditR9UwEdjCQpw+yBC8xa7DT1z8Hiv 56elzSP+7/5s8FbfUg9N8I= Received: from oyster.localdomain (unknown [113.57.80.38]) by smtp8 (Coremail) with SMTP id NORpCgAHlYGpb9ZivuOGIA--.6977S2; Tue, 19 Jul 2022 16:47:51 +0800 (CST) From: Liao Junxuan To: u-boot@lists.denx.de Cc: Liao Junxuan Subject: [PATCH] net: emaclite: Avoid reading negative bytes Date: Tue, 19 Jul 2022 16:47:35 +0800 Message-Id: <20220719084735.446539-1-mikeljx@126.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: NORpCgAHlYGpb9ZivuOGIA--.6977S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrKw4DWrWxKrWxKw4xJr4UCFg_yoWxtFgE9r 1j9rW3ur1UZF12yr4YgFW5Z3yrtF48Zr1vq3y0gayrA34Sv3yvqrykZa15JFn3Gr43CrZ8 Gr97Xry7Aa40qjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xR3nO_7UUUUU== X-Originating-IP: [113.57.80.38] X-CM-SenderInfo: pplnvzlm06ij2wof0z/1tbimhdDBlpEIJ7hewAAsy X-Mailman-Approved-At: Tue, 19 Jul 2022 17:29:40 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean As far as I know, an IP packet isn't necessarily shorter than an ARP packet, and if length < first_read, xemaclite_alignedread() goes into an infinite loop. --- drivers/net/xilinx_emaclite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 43fc36dc..134973a5 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -526,7 +526,7 @@ try_again: } /* Read the rest of the packet which is longer then first read */ - if (length != first_read) + if (length > first_read) xemaclite_alignedread(addr + first_read, etherrxbuff + first_read, length - first_read); -- 2.37.1