Reviewed-by: Fu Siyuan <siyuan...@intel.com>

-----Original Message-----
From: Meenakshi Aggarwal [mailto:meenakshi.aggar...@nxp.com] 
Sent: Monday, September 25, 2017 11:06 PM
To: edk2-devel@lists.01.org; Ni, Ruiyu <ruiyu...@intel.com>; Carsey, Jaben 
<jaben.car...@intel.com>
Cc: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; Fu, Siyuan 
<siyuan...@intel.com>; Ye, Ting <ting...@intel.com>; Meenakshi Aggarwal 
<meenakshi.aggar...@nxp.com>; Udit Kumar <udit.ku...@nxp.com>; Vabhav Sharma 
<vabhav.sha...@nxp.com>
Subject: [PATCH v2] TFTP : tftp fix for full volume case

Issue :
When storage media is full, tftp was resulting in ASSERT
MdeModulePkg/Core/Dxe/Mem/Page.c, because number of pages
was zero.

Reason:
While doing tftp, function call ShellWriteFile was modifying
FileSize variable. In case of full disk it was coming out to be
Zero.

Fix:
Storage the original filesize in local variable, and use this
variable while freeing the pages.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Udit Kumar <udit.ku...@nxp.com>
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggar...@nxp.com>
Signed-off-by: Vabhav Sharma <vabhav.sha...@nxp.com>
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggar...@nxp.com>
---
 ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c 
b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
index 5c50797..fbde3bf 100755
--- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
+++ b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
@@ -284,6 +284,7 @@ ShellCommandRunTftp (
   EFI_HANDLE              Mtftp4ChildHandle;
   EFI_MTFTP4_PROTOCOL     *Mtftp4;
   UINTN                   FileSize;
+  UINTN                   DataSize;
   VOID                    *Data;
   SHELL_FILE_HANDLE       FileHandle;
   UINT16                  BlockSize;
@@ -294,6 +295,7 @@ ShellCommandRunTftp (
   AsciiRemoteFilePath = NULL;
   Handles             = NULL;
   FileSize            = 0;
+  DataSize            = 0;
   BlockSize           = MTFTP_DEFAULT_BLKSIZE;
 
   //
@@ -537,6 +539,7 @@ ShellCommandRunTftp (
       goto NextHandle;
     }
 
+    DataSize = FileSize;
     Status = ShellWriteFile (FileHandle, &FileSize, Data);
     if (!EFI_ERROR (Status)) {
       ShellStatus = SHELL_SUCCESS;
@@ -551,7 +554,7 @@ ShellCommandRunTftp (
     NextHandle:
 
     if (Data != NULL) {
-      gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Data, EFI_SIZE_TO_PAGES 
(FileSize));
+      gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Data, EFI_SIZE_TO_PAGES 
(DataSize));
     }
 
     CloseProtocolAndDestroyServiceChild (
-- 
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to