diff --git a/Library/OcAudioLib/OcAudioDump.c b/Library/OcAudioLib/OcAudioDump.c index 0819a3f48f997ad2a0e001cff6eb370d1f0b58e3..3a2bad365b4e356223674033f072f3ab92e97087 100644 --- a/Library/OcAudioLib/OcAudioDump.c +++ b/Library/OcAudioLib/OcAudioDump.c @@ -176,6 +176,7 @@ CHAR8 *mColors[HDA_CONFIG_DEFAULT_COLOR_OTHER + 1] = }; STATIC +EFIAPI VOID PrintHdaBuffer ( IN OUT CHAR8 **AsciiBuffer, @@ -190,14 +191,14 @@ PrintHdaBuffer ( CHAR8 *NewBuffer; UINTN NewBufferSize; - VA_START (Marker, FormatString); - AsciiVSPrint (Tmp, sizeof (Tmp), FormatString, Marker); - VA_END (Marker); - if (*AsciiBuffer == NULL) { return; } + VA_START (Marker, FormatString); + AsciiVSPrint (Tmp, sizeof (Tmp), FormatString, Marker); + VA_END (Marker); + Status = AsciiStrCatS (*AsciiBuffer, *AsciiBufferSize, Tmp); if (Status == EFI_BUFFER_TOO_SMALL) { if (OcOverflowMulUN (*AsciiBufferSize, 2, &NewBufferSize)) { @@ -205,6 +206,11 @@ PrintHdaBuffer ( } NewBuffer = ReallocatePool (*AsciiBufferSize, NewBufferSize, *AsciiBuffer); if (NewBuffer == NULL) { + FreePool (*AsciiBuffer); + + *AsciiBuffer = NULL; + *AsciiBufferSize = 0; + return; } @@ -616,11 +622,13 @@ OcAudioDump ( // // Save dumped controller data to file. // - UnicodeSPrint (TmpFileName, sizeof (TmpFileName), L"Controller%u.txt", Index); - Status = SetFileData (Root, TmpFileName, FileBuffer, AsciiStrSize (FileBuffer)); - DEBUG ((DEBUG_INFO, "OCAU: Dumped HDA controller %u info result - %r\n", Index, Status)); + if (FileBuffer != NULL) { + UnicodeSPrint (TmpFileName, sizeof (TmpFileName), L"Controller%u.txt", Index); + Status = SetFileData (Root, TmpFileName, FileBuffer, (UINT32) AsciiStrSize (FileBuffer)); + DEBUG ((DEBUG_INFO, "OCAU: Dumped HDA controller %u info result - %r\n", Index, Status)); - FreePool (FileBuffer); + FreePool (FileBuffer); + } } // @@ -714,11 +722,13 @@ OcAudioDump ( // // Save dumped codec data to file. // - UnicodeSPrint (TmpFileName, sizeof (TmpFileName), L"Codec%u.txt", Index); - Status = SetFileData (Root, TmpFileName, FileBuffer, AsciiStrSize (FileBuffer)); - DEBUG ((DEBUG_INFO, "OCAU: Dumped HDA codec %u info result - %r\n", Index, Status)); + if (FileBuffer != NULL) { + UnicodeSPrint (TmpFileName, sizeof (TmpFileName), L"Codec%u.txt", Index); + Status = SetFileData (Root, TmpFileName, FileBuffer, (UINT32) AsciiStrSize (FileBuffer)); + DEBUG ((DEBUG_INFO, "OCAU: Dumped HDA codec %u info result - %r\n", Index, Status)); - FreePool (FileBuffer); + FreePool (FileBuffer); + } } return EFI_SUCCESS; diff --git a/Staging/AudioDxe/HdaCodec/HdaCodecInfo.c b/Staging/AudioDxe/HdaCodec/HdaCodecInfo.c index 40770d3abf966c18e68a27a1194651a1591b4ee9..bca5f0be1bc0a0e3b2b0b45a502df65fd4178079 100644 --- a/Staging/AudioDxe/HdaCodec/HdaCodecInfo.c +++ b/Staging/AudioDxe/HdaCodec/HdaCodecInfo.c @@ -33,8 +33,9 @@ HdaCodecInfoGetAddress ( { HDA_CODEC_INFO_PRIVATE_DATA *HdaPrivateData; - ASSERT (This != NULL); - ASSERT (Address != NULL); + if (This == NULL || Address == NULL) { + return EFI_INVALID_PARAMETER; + } HdaPrivateData = HDA_CODEC_INFO_PRIVATE_DATA_FROM_THIS (This); diff --git a/Staging/AudioDxe/HdaController/HdaControllerInfo.c b/Staging/AudioDxe/HdaController/HdaControllerInfo.c index 399e389e3d7f9ab582800f7d1e86ca36827fdd70..fb9fbeb482f678256ac51d8a3f47a4058bd9a2d8 100644 --- a/Staging/AudioDxe/HdaController/HdaControllerInfo.c +++ b/Staging/AudioDxe/HdaController/HdaControllerInfo.c @@ -33,8 +33,9 @@ HdaControllerInfoGetName ( { HDA_CONTROLLER_INFO_PRIVATE_DATA *HdaPrivateData; - ASSERT (This != NULL); - ASSERT (Name != NULL); + if (This == NULL || Name == NULL) { + return EFI_INVALID_PARAMETER; + } HdaPrivateData = HDA_CONTROLLER_INFO_PRIVATE_DATA_FROM_THIS (This); *Name = HdaPrivateData->HdaControllerDev->Name; @@ -51,8 +52,9 @@ HdaControllerInfoGetVendorId ( { HDA_CONTROLLER_INFO_PRIVATE_DATA *HdaPrivateData; - ASSERT (This != NULL); - ASSERT (VendorId != NULL); + if (This == NULL || VendorId == NULL) { + return EFI_INVALID_PARAMETER; + } HdaPrivateData = HDA_CONTROLLER_INFO_PRIVATE_DATA_FROM_THIS (This); *VendorId = HdaPrivateData->HdaControllerDev->VendorId;