From nobody Sat Nov 2 14:29:40 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1487559980364975.0369538864435; Sun, 19 Feb 2017 19:06:20 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 09A5E821E8; Sun, 19 Feb 2017 19:06:19 -0800 (PST) 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 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 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,184,1484035200"; d="scan'208";a="227327130" From: Hao Wu To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Hao Wu , Feng Tian MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Feng Tian --- 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/MdeModulePk= g/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 @@ =20 It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. =20 - 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -1265,7 +1265,7 @@ SdMmcCreateTrb ( goto Error; } =20 - if (Trb->DataLen < Trb->BlockSize) { + if ((Trb->DataLen !=3D 0) && (Trb->DataLen < Trb->BlockSize)) { Trb->BlockSize =3D (UINT16)Trb->DataLen; } =20 diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c b/MdeModulePkg/Bu= s/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 =20 - 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -1032,7 +1032,7 @@ EmmcPeimCreateTrb ( goto Error; } =20 - if (Trb->DataLen < Trb->BlockSize) { + if ((Trb->DataLen !=3D 0) && (Trb->DataLen < Trb->BlockSize)) { Trb->BlockSize =3D (UINT16)Trb->DataLen; } =20 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 =20 - 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -1032,7 +1032,7 @@ SdPeimCreateTrb ( goto Error; } =20 - if (Trb->DataLen < Trb->BlockSize) { + if ((Trb->DataLen !=3D 0) && (Trb->DataLen < Trb->BlockSize)) { Trb->BlockSize =3D (UINT16)Trb->DataLen; } =20 --=20 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel