From patchwork Thu Jun 29 00:29:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 129087 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9A23442D85; Thu, 29 Jun 2023 02:30:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F48340EDB; Thu, 29 Jun 2023 02:30:00 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A0A4740DF6 for ; Thu, 29 Jun 2023 02:29:59 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 9BB092083953; Wed, 28 Jun 2023 17:29:58 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9BB092083953 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1687998598; bh=fBwly23iLgKqIIcLHxwnol7KiJMZihr5ekLrCemIOAo=; h=From:To:Cc:Subject:Date:Reply-To:From; b=ZVXrnJ4z8wfRcMAVPh2xmHWTAkH0KslvW3l6/NmI4Md7Wxtp30TlW0eKo0ZOuc2PK fLpZxkpEpUAM1lF6+O5D/yKE44vu/3Pyptoc872NndO2idKfz4CMHkMYEbQGa39PqF o7yNtofrQZYBB7wuzrmT1PnUCWDIPeUCWs1Do1FE= From: longli@linuxonhyperv.com To: Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org, stable.dpdk.org@linux.microsoft.com, Stephen Hemminger , Long Li Subject: [PATCH] net/netvsc: fix bogus sizeof calculation Date: Wed, 28 Jun 2023 17:29:57 -0700 Message-Id: <1687998597-11972-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: longli@microsoft.com Errors-To: dev-bounces@dpdk.org From: Stephen Hemminger Found by cppcheck. drivers/net/netvsc/hn_rndis.c:332:21: warning: Found calculation inside sizeof(). [sizeofCalculation] if (len < sizeof(3 * sizeof(uint32_t))) { Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") Signed-off-by: Stephen Hemminger Signed-off-by: Long Li Acked-by: Tyler Retzlaff --- drivers/net/netvsc/hn_rndis.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c index e6f1f28768..29c6009b2c 100644 --- a/drivers/net/netvsc/hn_rndis.c +++ b/drivers/net/netvsc/hn_rndis.c @@ -329,7 +329,8 @@ void hn_rndis_receive_response(struct hn_data *hv, hn_rndis_dump(data); - if (len < sizeof(3 * sizeof(uint32_t))) { + /* Check we can read first three data fields from RNDIS header */ + if (len < 3 * sizeof(uint32_t)) { PMD_DRV_LOG(ERR, "missing RNDIS header %u", len); return;