Revision: 17859
http://sourceforge.net/p/edk2/code/17859
Author: oliviermartin
Date: 2015-07-07 11:26:27 +0000 (Tue, 07 Jul 2015)
Log Message:
-----------
MdeModulePkg/PartitionDxe: Fix media probe
The call in ProbeMediaStatus() 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.
In addition to avoiding the crash, that way, the media probe does not
depend anymore on the way the EFI_DISK_IO_PROTOCOL implementation deals
with a NULL value of the destination buffer pointer as the UEFI
specification does not specify the expected behaviour.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <[email protected]>
Reviewed-by: Olivier Martin <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
Modified: trunk/edk2/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
2015-07-07 09:29:54 UTC (rev 17858)
+++ trunk/edk2/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
2015-07-07 11:26:27 UTC (rev 17859)
@@ -576,11 +576,15 @@
)
{
EFI_STATUS Status;
+ UINT8 Buffer[1];
//
- // Read 1 byte from offset 0 but passing NULL as buffer pointer
+ // Read 1 byte from offset 0 to check if the MediaId is still valid.
+ // The reading operation is synchronious thus it is not worth it to
+ // allocate a buffer from the pool. The destination buffer for the
+ // data is in the stack.
//
- Status = DiskIo->ReadDisk (DiskIo, MediaId, 0, 1, NULL);
+ Status = DiskIo->ReadDisk (DiskIo, MediaId, 0, 1, (VOID*)Buffer);
if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
return Status;
}
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits