From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id EAE97AC046F for ; Wed, 28 Feb 2024 02:28:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ew6G5VtrcZxCXOUWzqKxvtNu7AslOXruwvaQWMnhxMk=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1709087301; v=1; b=w9wP5Nrd95GbIHNXmMpiS9arN4oYXS8sEq5bMO8DQfHL5AP2K+SfazUld2vJ669HwJc1M6wa EGej34u2DUZD92cAhXJqyb5MBfvGkmnwgVI6CYynjXb9JgSE/GreCJ7geRrsFVC6rSQkOxAJJSA 6Ii+XQOEFWDKfOX5dzHCyeew= X-Received: by 127.0.0.2 with SMTP id 1qq2YY7687511xPClnhhgWTb; Tue, 27 Feb 2024 18:28:21 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by mx.groups.io with SMTP id smtpd.web11.4428.1709087295523770648 for ; Tue, 27 Feb 2024 18:28:21 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="7285796" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7285796" X-Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 18:28:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="11893888" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 18:28:19 -0800 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Liming Gao , Jiaxin Wu , Ray Ni , Laszlo Ersek , Ard Biesheuvel , Sami Mujawar Subject: [edk2-devel] [PATCH v2 3/4] StandaloneMmPkg: Support to unregister MMI handler inside MMI handler Date: Wed, 28 Feb 2024 10:27:49 +0800 Message-Id: <20240228022750.873-4-zhiguang.liu@intel.com> In-Reply-To: <20240228022750.873-1-zhiguang.liu@intel.com> References: <20240228022750.873-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: KhDJ7Zm8m1LKwXL6egUqDeJWx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=w9wP5Nrd; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 Cc: Jiaxin Wu Cc: Ray Ni Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Sami Mujawar Signed-off-by: Zhiguang Liu --- StandaloneMmPkg/Core/Mmi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/StandaloneMmPkg/Core/Mmi.c b/StandaloneMmPkg/Core/Mmi.c index 0de6fd17fc..c1a1d76e85 100644 --- a/StandaloneMmPkg/Core/Mmi.c +++ b/StandaloneMmPkg/Core/Mmi.c @@ -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, -- 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116074): https://edk2.groups.io/g/devel/message/116074 Mute This Topic: https://groups.io/mt/104616994/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-