summaryrefslogtreecommitdiffstats
path: root/NetworkPkg
diff options
context:
space:
mode:
authorMike Beaton <mjsbeaton@gmail.com>2024-09-13 18:07:36 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-15 21:18:08 +0000
commit73dbb68006caf538d1b69a11e306b161526932f3 (patch)
tree85665f0cea966b51d78543e61cd27645b44c0b67 /NetworkPkg
parent1f32b5a30e473d5e37881c3232f7226dd8311b44 (diff)
downloadedk2-73dbb68006caf538d1b69a11e306b161526932f3.tar.gz
edk2-73dbb68006caf538d1b69a11e306b161526932f3.tar.bz2
edk2-73dbb68006caf538d1b69a11e306b161526932f3.zip
NetworkPkg/HttpBootDxe: Correctly uninstall HttpBootCallbackProtocol
The existing HttpBootUninstallCallback was passing the wrong handle (the PrivateData root controller handle, not the correct child IPv4 or IPv6 NIC controller handle; cf HttpBootInstallCallback for matching logic) and was also passing the address of a pointer to the interface to be removed rather than the pointer itself, so always failed with EFI_NOT_FOUND. This resulted in the prior behaviour that if multiple HTTP boot attempts were made, on the second and subsequent attempts the instance of this protocol installed by the first attempt would be re-used. As long as only one driver using the protocol is installed, this ends up producing the same results as if the protocol had been uninstalled then reinstalled correctly. After this commit, the protocol is installed at the start of an HTTP boot attempt and uninstalled it at the end of it (assuming nothing else has accessed the protocol in a way which blocks the uninstall). It might seem attractive to add an ASSERT to confirm when debugging that the uninstall succeeds as expected, but this is recommended against because uninstallation of protocol interfaces is allowed to fail under the UEFI model: https://edk2.groups.io/g/devel/message/117469. An ASSERT could therefore arise from a sequence of events which is perfectly valid - or at least is out of the control of this driver. Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
Diffstat (limited to 'NetworkPkg')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootImpl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index 4f84e59a21..6f10bcff39 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;
}