From 5eae4ff0024318030495838fe50ed34f4c15711a Mon Sep 17 00:00:00 2001 From: Samer El-Haj-Mahmoud Date: Wed, 30 Mar 2016 07:12:51 +0800 Subject: 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 Signed-off-by: Tapan Shah Signed-off-by: Hao Wu Reviewed-by: Hao Wu Reviewed-by: Tapan Shah --- MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c | 2 +- MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'MdeModulePkg/Universal/Disk') 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.
+ (C) Copyright 2016 Hewlett Packard Enterprise Development LP
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 -- cgit v1.2.3