From 770f9aae09cb6291db5a28ca2eb1ebf5696e9418 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Fri, 27 Oct 2017 10:16:29 +0800 Subject: [PATCH] NetworkPkg/HttpBootDxe: Add check to avoid use NULL pointer Cc: Wu Hao A Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Hao Wu --- NetworkPkg/HttpBootDxe/HttpBootDxe.c | 50 +++++++++++++++------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c b/NetworkPkg/HttpBootDxe/HttpBootDxe.c index b1f9042ea3..8a61f51cc8 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c @@ -615,19 +615,21 @@ HttpBootIp4DxeDriverBindingStart ( return EFI_SUCCESS; ON_ERROR: - if (FirstStart) { - gBS->UninstallProtocolInterface ( - ControllerHandle, - &gEfiCallerIdGuid, - &Private->Id - ); - } - - HttpBootDestroyIp4Children (This, Private); - HttpBootConfigFormUnload (Private); + if (Private != NULL) { + if (FirstStart) { + gBS->UninstallProtocolInterface ( + ControllerHandle, + &gEfiCallerIdGuid, + &Private->Id + ); + } + + HttpBootDestroyIp4Children (This, Private); + HttpBootConfigFormUnload (Private); - if (FirstStart && Private != NULL) { - FreePool (Private); + if (FirstStart) { + FreePool (Private); + } } return Status; @@ -1144,19 +1146,21 @@ HttpBootIp6DxeDriverBindingStart ( return EFI_SUCCESS; ON_ERROR: - if (FirstStart) { - gBS->UninstallProtocolInterface ( - ControllerHandle, - &gEfiCallerIdGuid, - &Private->Id - ); - } + if (Private != NULL) { + if (FirstStart) { + gBS->UninstallProtocolInterface ( + ControllerHandle, + &gEfiCallerIdGuid, + &Private->Id + ); + } - HttpBootDestroyIp6Children(This, Private); - HttpBootConfigFormUnload (Private); + HttpBootDestroyIp6Children(This, Private); + HttpBootConfigFormUnload (Private); - if (FirstStart && Private != NULL) { - FreePool (Private); + if (FirstStart) { + FreePool (Private); + } } return Status; -- 2.39.2