From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 175C4821E7 for ; Sun, 19 Feb 2017 19:06:18 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 19 Feb 2017 19:06:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,184,1484035200"; d="scan'208";a="227327130" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga004.fm.intel.com with ESMTP; 19 Feb 2017 19:06:16 -0800 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Feng Tian Date: Mon, 20 Feb 2017 11:06:12 +0800 Message-Id: <1487559972-50420-1-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 Subject: [PATCH] MdeModulePkg/SdMmc: Avoid assigning 0 to the BlockSize of Trb X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Feb 2017 03:06:18 -0000 Refine code to avoid potential divide by zero when calculating block number. Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 4 ++-- MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c | 4 ++-- MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index ccbf355..aa75aa8 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -4,7 +4,7 @@ It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials 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 @@ -1265,7 +1265,7 @@ SdMmcCreateTrb ( goto Error; } - if (Trb->DataLen < Trb->BlockSize) { + if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) { Trb->BlockSize = (UINT16)Trb->DataLen; } diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c index 5a9e0b2..2c0baca 100644 --- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c +++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials 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 @@ -1032,7 +1032,7 @@ EmmcPeimCreateTrb ( goto Error; } - if (Trb->DataLen < Trb->BlockSize) { + if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) { Trb->BlockSize = (UINT16)Trb->DataLen; } diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c index 72efd56..23e6563 100644 --- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c +++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials 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 @@ -1032,7 +1032,7 @@ SdPeimCreateTrb ( goto Error; } - if (Trb->DataLen < Trb->BlockSize) { + if ((Trb->DataLen != 0) && (Trb->DataLen < Trb->BlockSize)) { Trb->BlockSize = (UINT16)Trb->DataLen; } -- 1.9.5.msysgit.0