Skip to content

Commit 692b6e2

Browse files
v-chhsiehProjectMuBot
authored andcommitted
[Cherry-Pick]MdeModulePkg SpiBus: Use correct GUID
Fix incorrect guid in SpiBusDxe and add null checking for AllocateZeroPool in the SpiBus driver. Signed-off-by: Jack Hsieh <[email protected]> (cherry picked from commit e1dee2b)
1 parent 8383b1a commit 692b6e2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

MdeModulePkg/Bus/Spi/SpiBus/SpiBus.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,17 @@ Transaction (
329329
((SpiChip->SpiHc->Attributes & HC_SUPPORTS_WRITE_THEN_READ_OPERATIONS) != HC_SUPPORTS_WRITE_THEN_READ_OPERATIONS))
330330
{
331331
// Convert to full duplex transaction
332-
DummyReadBuffer = AllocateZeroPool (WriteBytes);
333-
DummyWriteBuffer = AllocateZeroPool (ReadBytes);
332+
DummyReadBuffer = AllocateZeroPool (WriteBytes);
333+
if (DummyReadBuffer == NULL) {
334+
return EFI_OUT_OF_RESOURCES;
335+
}
336+
337+
DummyWriteBuffer = AllocateZeroPool (ReadBytes);
338+
if (DummyWriteBuffer == NULL) {
339+
FreePool (DummyReadBuffer);
340+
return EFI_OUT_OF_RESOURCES;
341+
}
342+
334343
SpiChip->BusTransaction.ReadBuffer = DummyReadBuffer;
335344
SpiChip->BusTransaction.ReadBytes = WriteBytes;
336345

MdeModulePkg/Bus/Spi/SpiBus/SpiBusDxe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ SpiBusEntry (
108108
// Get SpiHc from the SpiHcHandles
109109
Status = gBS->HandleProtocol (
110110
SpiHcHandles[HcIndex],
111-
&gEfiDevicePathProtocolGuid,
111+
&gEfiSpiHcProtocolGuid,
112112
(VOID **)&SpiHc
113113
);
114114

0 commit comments

Comments
 (0)