Revision: 13941
http://edk2.svn.sourceforge.net/edk2/?rev=13941&view=rev
Author: erictian
Date: 2012-11-14 05:12:40 +0000 (Wed, 14 Nov 2012)
Log Message:
-----------
MdeModulePkg/AtaAtapiPassThru: fix buffer overflow issue introduced by previous
patch(r13932).
Signed-off-by: Feng Tian <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Revision Links:
--------------
http://edk2.svn.sourceforge.net/edk2/?rev=13932&view=rev
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
Modified: trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c 2012-11-14
01:43:18 UTC (rev 13940)
+++ trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c 2012-11-14
05:12:40 UTC (rev 13941)
@@ -1908,6 +1908,7 @@
VOID *Buffer;
UINT32 Capability;
+ UINT32 PortImplementBitMap;
UINT8 MaxPortNumber;
UINT8 MaxCommandSlotNumber;
BOOLEAN Support64Bit;
@@ -1923,12 +1924,20 @@
// Collect AHCI controller information
//
Capability = AhciReadReg(PciIo, EFI_AHCI_CAPABILITY_OFFSET);
- MaxPortNumber = (UINT8) ((Capability & 0x1F) + 1);
//
// Get the number of command slots per port supported by this HBA.
//
MaxCommandSlotNumber = (UINT8) (((Capability & 0x1F00) >> 8) + 1);
Support64Bit = (BOOLEAN) (((Capability & BIT31) != 0) ? TRUE :
FALSE);
+
+ PortImplementBitMap = AhciReadReg(PciIo, EFI_AHCI_PI_OFFSET);
+ //
+ // Get the highest bit of implemented ports which decides how many bytes are
allocated for recived FIS.
+ //
+ MaxPortNumber = (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1);
+ if (MaxPortNumber == 0) {
+ return EFI_DEVICE_ERROR;
+ }
MaxReceiveFisSize = MaxPortNumber * sizeof (EFI_AHCI_RECEIVED_FIS);
Status = PciIo->AllocateBuffer (
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits