diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index c3331def82..55a1e43f06 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -3699,8 +3699,10 @@ CreatePopulateInstallShellProtocol ( ); if (!EFI_ERROR(Status)) { OldProtocolNode = AllocateZeroPool(sizeof(SHELL_PROTOCOL_HANDLE_LIST)); - if (OldProtocolNode == NULL && !IsListEmpty (&ShellInfoObject.OldShellList.Link)) { - CleanUpShellProtocol (&mShellProtocol); + if (OldProtocolNode == NULL) { + if (!IsListEmpty (&ShellInfoObject.OldShellList.Link)) { + CleanUpShellProtocol (&mShellProtocol); + } Status = EFI_OUT_OF_RESOURCES; break; }