public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Mike Beaton" <mjsbeaton@gmail.com>
To: devel@edk2.groups.io
Cc: Mike Beaton <mjsbeaton@gmail.com>, Michael Brown <mcb30@ipxe.org>,
	Maciej Rabeda <maciej.rabeda@linux.intel.com>,
	Jiaxin Wu <jiaxin.wu@intel.com>
Subject: [edk2-devel] [PATCH v2] NetworkPkg/HttpBootDxe: Correctly uninstall HttpBootCallbackProtocol
Date: Sat,  6 Apr 2024 19:21:41 +0100	[thread overview]
Message-ID: <20240406182255.55442-1-mjsbeaton@gmail.com> (raw)

The existing uninstall call was passing the wrong handle (parent object,
not the correct child object) and additionally passing the address
of a pointer to the interface to be removed rather than the pointer
itself, so always failed with EFI_NOT_FOUND.

While it might seem attractive to ASSERT to ensure that the uninstall
proceeds as expected, uninstallation of protocol interfaces is allowed
to fail under the UEFI model. An ASSERT could therefore result in a
sequence of events which is perfectly valid - or at least is out of
the control of this driver - resulting in an ASSERT() failure.

Cc: Michael Brown <mcb30@ipxe.org>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>

xyz
---
 NetworkPkg/HttpBootDxe/HttpBootImpl.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index b4c61925b9..f78eef4a83 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -77,11 +77,19 @@ HttpBootUninstallCallback (
   IN HTTP_BOOT_PRIVATE_DATA  *Private
   )
 {
+  EFI_HANDLE  ControllerHandle;
+
   if (Private->HttpBootCallback == &Private->LoadFileCallback) {
+    if (!Private->UsingIpv6) {
+      ControllerHandle = Private->Ip4Nic->Controller;
+    } else {
+      ControllerHandle = Private->Ip6Nic->Controller;
+    }
+
     gBS->UninstallProtocolInterface (
-           Private->Controller,
+           ControllerHandle,
            &gEfiHttpBootCallbackProtocolGuid,
-           &Private->HttpBootCallback
+           Private->HttpBootCallback
            );
     Private->HttpBootCallback = NULL;
   }
-- 
2.44.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117470): https://edk2.groups.io/g/devel/message/117470
Mute This Topic: https://groups.io/mt/105371091/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



             reply	other threads:[~2024-04-06 18:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-06 18:21 Mike Beaton [this message]
2024-04-08 13:51 ` [edk2-devel] [PATCH v2] NetworkPkg/HttpBootDxe: Correctly uninstall HttpBootCallbackProtocol Mike Beaton

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=20240406182255.55442-1-mjsbeaton@gmail.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