From: Leif Lindholm <leif.lindholm@linaro.org>
To: Jian J Wang <jian.j.wang@intel.com>
Cc: edk2-devel@lists.01.org, Ruiyu Ni <ruiyu.ni@intel.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Star Zeng <star.zeng@intel.com>
Subject: Re: [PATCH 1/2] MdeModulePkg/Core: fill logic hole in MemoryProtectionCpuArchProtocolNotify
Date: Tue, 6 Nov 2018 12:07:32 +0000 [thread overview]
Message-ID: <20181106120732.kry6j534ovmo7xlj@bivouac.eciton.net> (raw)
In-Reply-To: <20181103064221.4764-2-jian.j.wang@intel.com>
On Sat, Nov 03, 2018 at 02:42:20PM +0800, Jian J Wang wrote:
> At the end of of MemoryProtectionCpuArchProtocolNotify there's cleanup
> code to free resource. But at line 978, 994, 1005 the function returns
> directly. This patch use "goto" to replace "return" to make sure the
> resource is freed before exit.
>
> 1029: CoreCloseEvent (Event);
> 1030: return;
>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
> ---
> MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 42 +++++++++++++--------------
> 1 file changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
> index 6298b67db1..30e5c5153c 100644
> --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
> +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
> @@ -975,7 +975,7 @@ MemoryProtectionCpuArchProtocolNotify (
> DEBUG ((DEBUG_INFO, "MemoryProtectionCpuArchProtocolNotify:\n"));
> Status = CoreLocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&gCpu);
> if (EFI_ERROR (Status)) {
> - return;
> + goto Done;
> }
>
> //
> @@ -991,7 +991,7 @@ MemoryProtectionCpuArchProtocolNotify (
> HeapGuardCpuArchProtocolNotify ();
>
> if (mImageProtectionPolicy == 0) {
> - return;
> + goto Done;
> }
>
> Status = gBS->LocateHandleBuffer (
> @@ -1002,7 +1002,7 @@ MemoryProtectionCpuArchProtocolNotify (
> &HandleBuffer
> );
> if (EFI_ERROR (Status) && (NoHandles == 0)) {
> - return ;
> + goto Done;
> }
>
> for (Index = 0; Index < NoHandles; Index++) {
> @@ -1026,8 +1026,8 @@ MemoryProtectionCpuArchProtocolNotify (
> ProtectUefiImage (LoadedImage, LoadedImageDevicePath);
> }
>
> +Done:
> CoreCloseEvent (Event);
> - return;
> }
>
> /**
I have no comments on the bits above, but everything below here looks
like it's only ruining the indentation without any functional changes
at all.
/
Leif
> @@ -1136,24 +1136,24 @@ CoreInitializeMemoryProtection (
> GetPermissionAttributeForMemoryType (EfiConventionalMemory));
>
> if (mImageProtectionPolicy != 0 || PcdGet64 (PcdDxeNxMemoryProtectionPolicy) != 0) {
> - Status = CoreCreateEvent (
> - EVT_NOTIFY_SIGNAL,
> - TPL_CALLBACK,
> - MemoryProtectionCpuArchProtocolNotify,
> - NULL,
> - &Event
> - );
> - ASSERT_EFI_ERROR(Status);
> + Status = CoreCreateEvent (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + MemoryProtectionCpuArchProtocolNotify,
> + NULL,
> + &Event
> + );
> + ASSERT_EFI_ERROR(Status);
>
> - //
> - // Register for protocol notifactions on this event
> - //
> - Status = CoreRegisterProtocolNotify (
> - &gEfiCpuArchProtocolGuid,
> - Event,
> - &Registration
> - );
> - ASSERT_EFI_ERROR(Status);
> + //
> + // Register for protocol notifactions on this event
> + //
> + Status = CoreRegisterProtocolNotify (
> + &gEfiCpuArchProtocolGuid,
> + Event,
> + &Registration
> + );
> + ASSERT_EFI_ERROR(Status);
> }
>
> //
> --
> 2.16.2.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2018-11-06 12:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-03 6:42 [PATCH 0/2] fix ineffective guard page issue Jian J Wang
2018-11-03 6:42 ` [PATCH 1/2] MdeModulePkg/Core: fill logic hole in MemoryProtectionCpuArchProtocolNotify Jian J Wang
2018-11-06 12:07 ` Leif Lindholm [this message]
2018-11-03 6:42 ` [PATCH 2/2] MdeModulePkg/Core: fix ineffective guard page issue Jian J Wang
2018-11-06 12:09 ` Leif Lindholm
2018-11-07 0:38 ` Wang, Jian J
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181106120732.kry6j534ovmo7xlj@bivouac.eciton.net \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox