StandaloneMmPkg: Support to unregister MMI handler inside MMI handler

To support unregister MMI handler inside MMI handler itself,
get next node before MMI handler is executed, since LIST_ENTRY that
Link points to may be freed if unregister MMI handler in MMI 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>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Message-Id: <20240301030133.628-4-zhiguang.liu@intel.com>
This commit is contained in:
Zhiguang Liu 2024-03-01 11:01:32 +08:00 committed by mergify[bot]
parent 17b2872200
commit 049ff6c39c
1 changed files with 7 additions and 2 deletions

View File

@ -154,9 +154,14 @@ MmiManage (
Head = &MmiEntry->MmiHandlers;
}
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
for (Link = Head->ForwardLink; Link != Head;) {
MmiHandler = CR (Link, MMI_HANDLER, Link, MMI_HANDLER_SIGNATURE);
//
// To support unregister MMI handler inside MMI handler itself,
// get next node before handler is executed, since LIST_ENTRY that
// Link points to may be freed if unregister MMI handler.
//
Link = Link->ForwardLink;
Status = MmiHandler->Handler (
(EFI_HANDLE)MmiHandler,
Context,