From 3d2367a2a748e87220a8aa5aa006448759d11be1 Mon Sep 17 00:00:00 2001 From: sfu5 Date: Tue, 14 May 2013 03:01:51 +0000 Subject: [PATCH] Fix bug in PXE driver: memory may be freed before use. Signed-off-by: Fu Siyuan Reviewed-by: Ye Ting Reviewed-by: Ouyang Qian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14354 6f19259b-4bc3-4df7-8a09-765794883524 --- NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c index 0b2743d127..8ee831f521 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c @@ -1353,9 +1353,6 @@ ON_ERROR: &gEfiCallerIdGuid, &Private->Id ); - if (Private != NULL) { - FreePool (Private); - } } if (IpVersion == IP_VERSION_4) { @@ -1364,6 +1361,10 @@ ON_ERROR: PxeBcDestroyIp6Children (This, Private); } + if (FirstStart && Private != NULL) { + FreePool (Private); + } + return Status; }