AUDK MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c contains incorrect code after a refactor to avoid uninitialized variable warnings (which corresponded to genuine, potentially harmful uses of uninitialized stack variables).
The same uninit issue has now been spotted by two separate programmers offering PRs to EDK2 (as well as by myself while attempting to work on EDK2 CLANG CI, which is why I spotted this AUDK issue), and so will probably shortly get fixed in EDK2 one way or another here: https://github.com/tianocore/edk2/pull/11803/files
The issue in the AUDK file is that, while uninitialized variables are no longer accessed, and unpleasant goto Done: code has been removed, unfortunately the originally intended effect of the goto Done: code has been lost - we just ASSERT then carry on with a NULL pointer; whereas we should ASSERT, free whatever has actually been allocated to that point, then return NULL - as the original code was trying to do.
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1444
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1491
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1498
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1502
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1559
It is not clear whether it is worth writing a fix for this in AUDK at this point, or just carefully merging and restoring lost functionality on next rebase to EDK2.
AUDK MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c contains incorrect code after a refactor to avoid uninitialized variable warnings (which corresponded to genuine, potentially harmful uses of uninitialized stack variables).
The same uninit issue has now been spotted by two separate programmers offering PRs to EDK2 (as well as by myself while attempting to work on EDK2 CLANG CI, which is why I spotted this AUDK issue), and so will probably shortly get fixed in EDK2 one way or another here: https://github.com/tianocore/edk2/pull/11803/files
The issue in the AUDK file is that, while uninitialized variables are no longer accessed, and unpleasant
goto Done:code has been removed, unfortunately the originally intended effect of thegoto Done:code has been lost - we just ASSERT then carry on with a NULL pointer; whereas we should ASSERT, free whatever has actually been allocated to that point, then return NULL - as the original code was trying to do.https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1444
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1491
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1498
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1502
https://github.com/acidanthera/audk/blob/80adbac459d8901bd00776de8c377a394346274d/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c#L1559
It is not clear whether it is worth writing a fix for this in AUDK at this point, or just carefully merging and restoring lost functionality on next rebase to EDK2.