From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 676172116325D for ; Mon, 15 Oct 2018 04:29:49 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Oct 2018 04:29:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,384,1534834800"; d="scan'208";a="78104189" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga007.fm.intel.com with ESMTP; 15 Oct 2018 04:29:47 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 15 Oct 2018 04:29:46 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.48]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.245]) with mapi id 14.03.0319.002; Mon, 15 Oct 2018 19:29:38 +0800 From: "Wu, Hao A" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" , "Zeng, Star" Thread-Topic: [edk2] [PATCH 05/11] MdeModulePkg/Usb: Make sure data from HW is no more than expected Thread-Index: AQHUZFGbIEeszAyyukuxyR2CaAJCFKUgK/zA Date: Mon, 15 Oct 2018 11:29:37 +0000 Message-ID: References: <20181015063833.61304-1-ruiyu.ni@intel.com> <20181015063833.61304-6-ruiyu.ni@intel.com> In-Reply-To: <20181015063833.61304-6-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 05/11] MdeModulePkg/Usb: Make sure data from HW is no more than expected X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 11:29:49 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Ruiyu Ni > Sent: Monday, October 15, 2018 2:38 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A; Yao, Jiewen; Zeng, Star > Subject: [edk2] [PATCH 05/11] MdeModulePkg/Usb: Make sure data from > HW is no more than expected >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Jiewen Yao > Cc: Star Zeng > Cc: Hao A Wu > --- > MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c | 9 ++++++--- > MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c | 7 ++++--- > MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 9 ++++++--- > 3 files changed, 16 insertions(+), 9 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > index fea6f47f4c..168280be81 100644 > --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c > @@ -1009,9 +1009,12 @@ EhcMonitorAsyncRequests ( > ProcBuf =3D NULL; >=20 > if (Urb->Result =3D=3D EFI_USB_NOERROR) { > - ASSERT (Urb->Completed <=3D Urb->DataLen); > - > - ProcBuf =3D AllocatePool (Urb->Completed); > + // > + // Make sure the data received from HW is no more than expected. > + // > + if (Urb->Completed <=3D Urb->DataLen) { > + ProcBuf =3D AllocatePool (Urb->Completed); > + } >=20 > if (ProcBuf =3D=3D NULL) { > EhcUpdateAsyncRequest (Ehc, Urb); > diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c > b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c > index 90f010c998..f7510f3ec0 100644 > --- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c > +++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c > @@ -2,7 +2,7 @@ >=20 > The EHCI register operation routines. >=20 > -Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
> +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at > @@ -1001,11 +1001,12 @@ UhciMonitorAsyncReqList ( >=20 > // > // Copy the data to temporary buffer if there are some > - // data transferred. We may have zero-length packet > + // data transferred. We may have zero-length packet. > + // Make sure the data received from HW is no more than expected. > // > Data =3D NULL; >=20 > - if (QhResult.Complete !=3D 0) { > + if ((QhResult.Complete !=3D 0) && (QhResult.Complete <=3D AsyncReq- > >DataLen)) { > Data =3D AllocatePool (QhResult.Complete); >=20 > if (Data =3D=3D NULL) { > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > index 6a2ef4cd5d..166c44bf5e 100644 > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > @@ -1556,9 +1556,12 @@ XhcMonitorAsyncRequests ( > // > ProcBuf =3D NULL; > if (Urb->Result =3D=3D EFI_USB_NOERROR) { > - ASSERT (Urb->Completed <=3D Urb->DataLen); > - > - ProcBuf =3D AllocateZeroPool (Urb->Completed); > + // > + // Make sure the data received from HW is no more than expected. > + // > + if (Urb->Completed <=3D Urb->DataLen) { > + ProcBuf =3D AllocateZeroPool (Urb->Completed); > + } >=20 > if (ProcBuf =3D=3D NULL) { > XhcUpdateAsyncRequest (Xhc, Urb); > -- > 2.16.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel