]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Partition: Fix media probe
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 25 Jan 2018 09:44:16 +0000 (17:44 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 26 Jan 2018 10:56:25 +0000 (18:56 +0800)
The call in ProbeMediaStatusEx() to the ReadDisk() function of the
EFI_DISK_IO_PROTOCOL interface implemented in DiskIoDxe/DiskIo.c
crashed in DiskIo2ReadWriteDisk() because of the NULL value of
the destination buffer pointer.

Pass the address of a buffer in the stack instead of a NULL
pointer.

The similar fix was applied to ProbeMediaStatus in commit
df473cc1fc9acd1a623ec7e05276f2f0635c19d2
* MdeModulePkg/PartitionDxe: Fix media probe

Somehow ProbeMediaStatusEx() wasn't changed together.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Tested-by: Jian J Wang <jian.j.wang@intel.com>
MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c

index bb9d0b70cec465f56706ad85fecb65813ba1a0b8..46c0877ceeae4455df8128cc397af2feac92786f 100644 (file)
@@ -4,7 +4,7 @@
   of the raw block devices media. Currently "El Torito CD-ROM", UDF, Legacy\r
   MBR, and GPT partition schemes are supported.\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -777,11 +777,15 @@ ProbeMediaStatusEx (
   )\r
 {\r
   EFI_STATUS                 Status;\r
+  UINT8                      Buffer[1];\r
 \r
   //\r
-  // Read 1 byte from offset 0 but passing NULL as buffer pointer\r
+  // Read 1 byte from offset 0 to check if the MediaId is still valid.\r
+  // The reading operation is synchronious thus it is not worth it to\r
+  // allocate a buffer from the pool. The destination buffer for the\r
+  // data is in the stack.\r
   //\r
-  Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, NULL);\r
+  Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, (VOID*)Buffer);\r
   if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {\r
     return Status;\r
   }\r