From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 55B89AC0A3E for ; Wed, 16 Aug 2023 05:38:11 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zI2BrywlRp2GamQTjFj9pF8humktxIP+ZRyyI6iqGGE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1692164289; v=1; b=ae5DQH9EIxncr3IVO5MXmQK7BfIMguCOj50PmZBwPUhDm7Twx4wY+NYl/KkQz/zNRosHGoaK 7OOxdg8hZyQc1LSw4DrZdL9bMT3lhbaLcWnhSrBQzoc/i53WPcoVy6v8jjz+di7KcdwYEGZNMjp aSsb/HO2X8a/BZR+LN98/768= X-Received: by 127.0.0.2 with SMTP id 550nYY7687511xQGWbcS6A5i; Tue, 15 Aug 2023 22:38:09 -0700 X-Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mx.groups.io with SMTP id smtpd.web11.154668.1692164289223126602 for ; Tue, 15 Aug 2023 22:38:09 -0700 X-Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6887b3613e4so458978b3a.3 for ; Tue, 15 Aug 2023 22:38:09 -0700 (PDT) X-Gm-Message-State: Fpwaa1XFGoYzfDD5xvN7l2FVx7686176AA= X-Google-Smtp-Source: AGHT+IEQHN8ZwGbz9+5hcV00hIAd6EHln9OXbu/gfu+XFYhEJtvZ/DQMzneSnj8vX84ZU9qxV53URw== X-Received: by 2002:a05:6a21:7985:b0:13b:c4a8:1a68 with SMTP id bh5-20020a056a21798500b0013bc4a81a68mr1215337pzc.34.1692164288561; Tue, 15 Aug 2023 22:38:08 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id p2-20020aa78602000000b006889081281bsm424737pfn.138.2023.08.15.22.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 22:38:08 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 1/2] MdeModulePkg/Bus/Pci/UhciDxe: Fix BAD_SHIFT Coverity issue Date: Wed, 16 Aug 2023 11:08:02 +0530 Message-Id: <20230816053803.1142517-2-rsingh@ventanamicro.com> In-Reply-To: <20230816053803.1142517-1-rsingh@ventanamicro.com> References: <20230816053803.1142517-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=ae5DQH9E; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Ranbir Singh The function UhciConvertPollRate has a check ASSERT (Interval !=3D 0); but this comes into play only in DEBUG mode. In Release mode, there is no handling if the Interval parameter value is ZERO. To avoid shifting by a negative amount later in the code flow in this undesirable case, it is better to handle it as well by treating it same as if 1 is sent. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4211 Cc: Hao A Wu Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c b/MdeModulePkg/Bus/Pc= i/UhciDxe/UhciSched.c index c08f9496969b..408e7d5ab7f3 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c @@ -197,7 +197,7 @@ UhciDestoryFrameList ( }=0D =0D /**=0D - Convert the poll rate to the maxium 2^n that is smaller=0D + Convert the poll rate to the maximum 2^n that is smaller=0D than Interval.=0D =0D @param Interval The poll rate to convert.=0D @@ -214,6 +214,14 @@ UhciConvertPollRate ( =0D ASSERT (Interval !=3D 0);=0D =0D + //=0D + // To safeguard RELEASE mode wherein ASSERT is effectively not there,=0D + // if inadvertently Interval is still 0 here, treat it the same as 1.=0D + //=0D + if (Interval =3D=3D 0) {=0D + Interval =3D 1;=0D + }=0D +=0D //=0D // Find the index (1 based) of the highest non-zero bit=0D //=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107789): https://edk2.groups.io/g/devel/message/107789 Mute This Topic: https://groups.io/mt/100774224/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-