From: Star Zeng Date: Sun, 12 Jun 2016 04:45:09 +0000 (+0800) Subject: MdeModulePkg DxeS3BootScriptLib: Check (mSmst != NULL) before freeing SMRAM X-Git-Tag: edk2-stable201903~6866 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=d6f38e374ece00f1f8176007c9d3e8eff1f2308f MdeModulePkg DxeS3BootScriptLib: Check (mSmst != NULL) before freeing SMRAM There is static scan tool reports BootScriptSave.c:628:'mSmst' is explicitly dereferenced. The patch is to check (mSmst != NULL) before freeing SMRAM at BootScriptSave.c:628. Cc: Shumin Qiu Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Shumin Qiu --- diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c index f6de986e08..0ff73211ac 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c @@ -624,7 +624,7 @@ S3BootScriptLibDeinitialize ( Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, 0); ASSERT_EFI_ERROR (Status); } - if (mS3BootScriptTableSmmAllocated) { + if ((mSmst != NULL) && mS3BootScriptTableSmmAllocated) { Status = mSmst->SmmFreePool (mS3BootScriptTableSmmPtr); ASSERT_EFI_ERROR (Status); Status = PcdSet64S (PcdS3BootScriptTablePrivateSmmDataPtr, 0);