diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c
index 0bda1687f0..4c607125a6 100644
--- a/NetworkPkg/Ip6Dxe/Ip6Driver.c
+++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding and service binding protocol for IP6 driver.
- Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
This program and the accompanying materials
@@ -564,7 +564,7 @@ Ip6DriverBindingStart (
NULL
);
if (EFI_ERROR (Status)) {
- goto ON_ERROR;
+ goto FREE_SERVICE;
}
//
@@ -573,7 +573,7 @@ Ip6DriverBindingStart (
//
Status = Ip6ConfigReadConfigData (IpSb->MacString, &IpSb->Ip6ConfigInstance);
if (EFI_ERROR (Status)) {
- goto ON_ERROR;
+ goto UNINSTALL_PROTOCOL;
}
//
@@ -588,7 +588,7 @@ Ip6DriverBindingStart (
DataItem->Data.Ptr
);
if (EFI_ERROR(Status) && Status != EFI_NOT_READY) {
- goto ON_ERROR;
+ goto UNINSTALL_PROTOCOL;
}
}
@@ -604,7 +604,7 @@ Ip6DriverBindingStart (
DataItem->Data.Ptr
);
if (EFI_ERROR(Status)) {
- goto ON_ERROR;
+ goto UNINSTALL_PROTOCOL;
}
}
@@ -613,7 +613,7 @@ Ip6DriverBindingStart (
//
Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);
if (EFI_ERROR (Status)) {
- goto ON_ERROR;
+ goto UNINSTALL_PROTOCOL;
}
//
@@ -625,7 +625,7 @@ Ip6DriverBindingStart (
TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS
);
if (EFI_ERROR (Status)) {
- goto ON_ERROR;
+ goto UNINSTALL_PROTOCOL;
}
//
@@ -637,7 +637,7 @@ Ip6DriverBindingStart (
TICKS_PER_MS * IP6_ONE_SECOND_IN_MS
);
if (EFI_ERROR (Status)) {
- goto ON_ERROR;
+ goto UNINSTALL_PROTOCOL;
}
//
@@ -647,7 +647,17 @@ Ip6DriverBindingStart (
return EFI_SUCCESS;
-ON_ERROR:
+UNINSTALL_PROTOCOL:
+ gBS->UninstallMultipleProtocolInterfaces (
+ ControllerHandle,
+ &gEfiIp6ServiceBindingProtocolGuid,
+ &IpSb->ServiceBinding,
+ &gEfiIp6ConfigProtocolGuid,
+ Ip6Cfg,
+ NULL
+ );
+
+FREE_SERVICE:
Ip6CleanService (IpSb);
FreePool (IpSb);
return Status;