diff options
author | Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@hpe.com> | 2016-03-30 07:12:51 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-03-31 13:08:44 +0800 |
commit | 5eae4ff0024318030495838fe50ed34f4c15711a (patch) | |
tree | f442dc8bfba09de13aae33ffce307d58e14089e7 /MdeModulePkg | |
parent | 307a55fa0169ac990efe046b477db9ccac61b2e2 (diff) | |
download | edk2-5eae4ff0024318030495838fe50ed34f4c15711a.tar.gz edk2-5eae4ff0024318030495838fe50ed34f4c15711a.tar.bz2 edk2-5eae4ff0024318030495838fe50ed34f4c15711a.zip |
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')
-rw-r--r-- | MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c | 2 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c index 9df9b5b965..29dcbf72f7 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 0c1df9dc73..de11721232 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
|