* [Patch] ShellPkg/dblk: Avoid overwriting Media->IoAlign
@ 2018-04-02 23:29 Kornel Pal
0 siblings, 0 replies; only message in thread
From: Kornel Pal @ 2018-04-02 23:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Jaben Carsey, Ruiyu Ni
According to the UEFI Specification, data values in EFI_BLOCK_IO_MEDIA
are read-only.
This patch introduces a local variable to avoid overwriting IoAlign and
reduces unnecessary overallocation.
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Kornel Pal <kornelpal@gmail.com>
---
ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c
b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c
index 3632ca8a7a..b2cbae84f3 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c
@@ -39,6 +39,7 @@ DisplayTheBlocks(
UINT8 *Buffer;
UINT8 *OriginalBuffer;
UINTN BufferSize;
+ UINT32 IoAlign;
ShellStatus = SHELL_SUCCESS;
@@ -53,13 +54,14 @@ DisplayTheBlocks(
}
BufferSize = BlockIo->Media->BlockSize * BlockCount;
- if(BlockIo->Media->IoAlign == 0) {
- BlockIo->Media->IoAlign = 1;
+ IoAlign = BlockIo->Media->IoAlign;
+ if (IoAlign == 0) {
+ IoAlign = 1;
}
if (BufferSize > 0) {
- OriginalBuffer = AllocateZeroPool(BufferSize +
BlockIo->Media->IoAlign);
- Buffer = ALIGN_POINTER
(OriginalBuffer,BlockIo->Media->IoAlign);
+ OriginalBuffer = AllocateZeroPool(BufferSize + IoAlign - 1);
+ Buffer = ALIGN_POINTER (OriginalBuffer, IoAlign);
} else {
ShellPrintEx(-1,-1,L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n",
BlockIo->Media->BlockSize, BlockCount);
OriginalBuffer = NULL;
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-04-02 23:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-02 23:29 [Patch] ShellPkg/dblk: Avoid overwriting Media->IoAlign Kornel Pal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox