Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
ProcBuf = NULL;\r
\r
if (Urb->Result == EFI_USB_NOERROR) {\r
ProcBuf = NULL;\r
\r
if (Urb->Result == EFI_USB_NOERROR) {\r
- ASSERT (Urb->Completed <= Urb->DataLen);\r
-\r
- ProcBuf = AllocatePool (Urb->Completed);\r
+ //\r
+ // Make sure the data received from HW is no more than expected.\r
+ //\r
+ if (Urb->Completed <= Urb->DataLen) {\r
+ ProcBuf = AllocatePool (Urb->Completed);\r
+ }\r
\r
if (ProcBuf == NULL) {\r
EhcUpdateAsyncRequest (Ehc, Urb);\r
\r
if (ProcBuf == NULL) {\r
EhcUpdateAsyncRequest (Ehc, Urb);\r
\r
The EHCI register operation routines.\r
\r
\r
The EHCI register operation routines.\r
\r
-Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
//\r
// Copy the data to temporary buffer if there are some\r
\r
//\r
// Copy the data to temporary buffer if there are some\r
- // data transferred. We may have zero-length packet\r
+ // data transferred. We may have zero-length packet.\r
+ // Make sure the data received from HW is no more than expected.\r
- if (QhResult.Complete != 0) {\r
+ if ((QhResult.Complete != 0) && (QhResult.Complete <= AsyncReq->DataLen)) {\r
Data = AllocatePool (QhResult.Complete);\r
\r
if (Data == NULL) {\r
Data = AllocatePool (QhResult.Complete);\r
\r
if (Data == NULL) {\r
//\r
ProcBuf = NULL;\r
if (Urb->Result == EFI_USB_NOERROR) {\r
//\r
ProcBuf = NULL;\r
if (Urb->Result == EFI_USB_NOERROR) {\r
- ASSERT (Urb->Completed <= Urb->DataLen);\r
-\r
- ProcBuf = AllocateZeroPool (Urb->Completed);\r
+ //\r
+ // Make sure the data received from HW is no more than expected.\r
+ //\r
+ if (Urb->Completed <= Urb->DataLen) {\r
+ ProcBuf = AllocateZeroPool (Urb->Completed);\r
+ }\r
\r
if (ProcBuf == NULL) {\r
XhcUpdateAsyncRequest (Xhc, Urb);\r
\r
if (ProcBuf == NULL) {\r
XhcUpdateAsyncRequest (Xhc, Urb);\r