MdeModulePkg/SdMmc: Avoid assigning 0 to the BlockSize of Trb

Refine code to avoid potential divide by zero when calculating block
number.

Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
Hao Wu 2017-01-05 09:43:21 +08:00
parent ce8e582c06
commit 5422804653
3 changed files with 6 additions and 6 deletions

View File

@ -4,7 +4,7 @@
It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use.
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -1265,7 +1265,7 @@ SdMmcCreateTrb (
goto Error; goto Error;
} }
if (Trb->DataLen < Trb->BlockSize) { if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) {
Trb->BlockSize = (UINT16)Trb->DataLen; Trb->BlockSize = (UINT16)Trb->DataLen;
} }

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -1032,7 +1032,7 @@ EmmcPeimCreateTrb (
goto Error; goto Error;
} }
if (Trb->DataLen < Trb->BlockSize) { if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) {
Trb->BlockSize = (UINT16)Trb->DataLen; Trb->BlockSize = (UINT16)Trb->DataLen;
} }

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -1032,7 +1032,7 @@ SdPeimCreateTrb (
goto Error; goto Error;
} }
if (Trb->DataLen < Trb->BlockSize) { if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) {
Trb->BlockSize = (UINT16)Trb->DataLen; Trb->BlockSize = (UINT16)Trb->DataLen;
} }