From: Andrew Fish <afish@apple.com>
To: Arka Sharma <arka.sw1988@gmail.com>
Cc: edk2-devel@lists.01.org
Subject: Re: Closing events and releasing resources in notify function
Date: Thu, 23 Mar 2017 23:37:46 -0700 [thread overview]
Message-ID: <9C33D691-C2DF-4F19-933D-5D344B96554B@apple.com> (raw)
In-Reply-To: <CAPO=kN0VmZcnqSDQfsEc8AKDazQ+QZNZ+PzNcTTXkrzJfrLJXw@mail.gmail.com>
> On Mar 23, 2017, at 11:22 PM, Arka Sharma <arka.sw1988@gmail.com> wrote:
>
> Hi,
>
> Is it ok to close the event and release the resource allocated to be
> sent as context inside the notify function. May be something like this
>
> VOID
> EFIAPI
> NotifyRoutine (
> EFI_EVENT Event,
> VOID *Context
> )
> {
> //
> // Perform intended task
> //
> FreePool (Context);
> gBS->CloseEvent (Event);
You should close the event before you free the context, or you will have a race. You need to make sure there is no way for EFI to signal the event before you free the context.
This all assumes you don't have other code doing crazy stuff with the Context or Event. It would be a different answer for CreateEventEx()
Thanks,
Andrew Fish
> }
>
> In the above example Context was allocated before creating the event
> and passed as a parameter to CreateEvent().
>
> Regards,
> Arka
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2017-03-24 6:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-24 6:22 Closing events and releasing resources in notify function Arka Sharma
2017-03-24 6:37 ` Andrew Fish [this message]
2017-03-24 7:07 ` Arka Sharma
2017-03-24 7:08 ` Andrew Fish
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=9C33D691-C2DF-4F19-933D-5D344B96554B@apple.com \
--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