summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk/RamDiskDxe
diff options
context:
space:
mode:
authorSamer El-Haj-Mahmoud <samer.el-haj-mahmoud@hpe.com>2016-03-30 07:12:51 +0800
committerHao Wu <hao.a.wu@intel.com>2016-03-31 13:08:44 +0800
commit5eae4ff0024318030495838fe50ed34f4c15711a (patch)
treef442dc8bfba09de13aae33ffce307d58e14089e7 /MdeModulePkg/Universal/Disk/RamDiskDxe
parent307a55fa0169ac990efe046b477db9ccac61b2e2 (diff)
downloadedk2-5eae4ff0024318030495838fe50ed34f4c15711a.zip
edk2-5eae4ff0024318030495838fe50ed34f4c15711a.tar.gz
edk2-5eae4ff0024318030495838fe50ed34f4c15711a.tar.bz2
MdeModulePkg RamDiskDxe: Fix incorrect RAM disk memory address calculation
EndingAddress is calculated incorrectly. Original code calculates it as (StartingAddress + Size). Correct value should be (StartingAddress + Size - 1. Note: Besides the changes made by Samer, Hao also fixed a similar issue in RamDiskImpl.c Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Samer El-Haj-Mahmoud <elhaj@hpe.com> Signed-off-by: Tapan Shah <tapandshah@hpe.com> Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Tapan Shah <tapandshah@hpe.com>
Diffstat (limited to 'MdeModulePkg/Universal/Disk/RamDiskDxe')
-rw-r--r--MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c2
-rw-r--r--MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c5
2 files changed, 4 insertions, 3 deletions
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
index 9df9b5b..29dcbf7 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
@@ -566,7 +566,7 @@ UpdateMainForm (
L" RAM Disk %d: [0x%lx, 0x%lx]\n",
Index,
PrivateData->StartingAddr,
- PrivateData->StartingAddr + PrivateData->Size
+ PrivateData->StartingAddr + PrivateData->Size - 1
);
StringId = HiiSetString (ConfigPrivate->HiiHandle, 0, RamDiskStr, NULL);
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c
index 0c1df9d..de11721 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c
@@ -2,6 +2,7 @@
The realization of EFI_RAM_DISK_PROTOCOL.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
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
@@ -50,7 +51,7 @@ RamDiskInitDeviceNode (
);
WriteUnaligned64 (
(UINT64 *) &(RamDiskDevNode->EndingAddr[0]),
- (UINT64) PrivateData->StartingAddr + PrivateData->Size
+ (UINT64) PrivateData->StartingAddr + PrivateData->Size - 1
);
CopyGuid (&RamDiskDevNode->TypeGuid, &PrivateData->TypeGuid);
RamDiskDevNode->Instance = PrivateData->InstanceNumber;
@@ -305,7 +306,7 @@ RamDiskUnregister (
// and type guid.
//
if ((StartingAddr == PrivateData->StartingAddr) &&
- (EndingAddr == PrivateData->StartingAddr + PrivateData->Size) &&
+ (EndingAddr == PrivateData->StartingAddr + PrivateData->Size - 1) &&
(CompareGuid (&RamDiskDevNode->TypeGuid, &PrivateData->TypeGuid))) {
//
// Uninstall the EFI_DEVICE_PATH_PROTOCOL & EFI_BLOCK_IO(2)_PROTOCOL