MdeModulePkg/SMM: Support to unregister SMI handler inside SMI handler

To support unregister SMI handler inside SMI handler itself,
get next node before SMI handler is executed, since LIST_ENTRY that
Link points to may be freed if unregister SMI handler in SMI handler
itself.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Message-Id: <20240301030133.628-2-zhiguang.liu@intel.com>
This commit is contained in:
Zhiguang Liu 2024-03-01 11:01:30 +08:00 committed by mergify[bot]
parent dcffad2491
commit ae1079b386
1 changed files with 7 additions and 1 deletions

View File

@ -134,8 +134,14 @@ SmiManage (
Head = &SmiEntry->SmiHandlers;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
for (Link = Head->ForwardLink; Link != Head;) {
SmiHandler = CR (Link, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);
//
// To support unregister SMI handler inside SMI handler itself,
// get next node before handler is executed, since LIST_ENTRY that
// Link points to may be freed if unregister SMI handler.
//
Link = Link->ForwardLink;
Status = SmiHandler->Handler (
(EFI_HANDLE)SmiHandler,