summaryrefslogtreecommitdiffstats
path: root/IntelSiliconPkg
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2017-08-01 11:50:39 +0800
committerHao Wu <hao.a.wu@intel.com>2017-08-02 08:54:36 +0800
commitbe61fcd2b095f39e250f309fe4a01cf170f5c8e7 (patch)
treef26c1ac7f582c4999c320b607af9e9aa09fbc865 /IntelSiliconPkg
parentf5046945b668403a9800e686f804a3ea1e9e79d7 (diff)
downloadedk2-be61fcd2b095f39e250f309fe4a01cf170f5c8e7.tar.gz
edk2-be61fcd2b095f39e250f309fe4a01cf170f5c8e7.tar.bz2
edk2-be61fcd2b095f39e250f309fe4a01cf170f5c8e7.zip
IntelSiliconPkg/IntelVTdDxe: Add explicit NULL pointer checks
Add explicit NULL pointer check to make the codes more straight-forward. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'IntelSiliconPkg')
-rw-r--r--IntelSiliconPkg/IntelVTdDxe/TranslationTable.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c b/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c
index 0cff2cc939..5af4a4627b 100644
--- a/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c
+++ b/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c
@@ -862,6 +862,8 @@ SetAccessAttribute (
VTD_SECOND_LEVEL_PAGING_ENTRY *SecondLevelPagingEntry;
UINT64 Pt;
+ SecondLevelPagingEntry = NULL;
+
DEBUG ((DEBUG_INFO,"SetAccessAttribute (S%04x B%02x D%02x F%02x) (0x%016lx - 0x%08x, %x)\n", Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function, BaseAddress, (UINTN)Length, IoMmuAccess));
VtdIndex = FindVtdIndexByPciDevice (Segment, SourceId, &ExtContextEntry, &ContextEntry);
@@ -884,7 +886,7 @@ SetAccessAttribute (
SecondLevelPagingEntry = (VOID *)(UINTN)LShiftU64 (ExtContextEntry->Bits.SecondLevelPageTranslationPointer, 12);
DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x B%02x D%02x F%02x)\n", SecondLevelPagingEntry, Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));
}
- } else {
+ } else if (ContextEntry != NULL) {
if (ContextEntry->Bits.Present == 0) {
SecondLevelPagingEntry = CreateSecondLevelPagingEntry (VtdIndex, 0);
DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x B%02x D%02x F%02x) New\n", SecondLevelPagingEntry, Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));
@@ -959,7 +961,7 @@ AlwaysEnablePageAttribute (
ExtContextEntry->Bits.SecondLevelPageTranslationPointer = Pt;
ExtContextEntry->Bits.DomainIdentifier = ((1 << (UINT8)((UINTN)mVtdUnitInformation[VtdIndex].CapReg.Bits.ND * 2 + 4)) - 1);
ExtContextEntry->Bits.Present = 1;
- } else {
+ } else if (ContextEntry != NULL) {
ContextEntry->Bits.SecondLevelPageTranslationPointer = Pt;
ContextEntry->Bits.DomainIdentifier = ((1 << (UINT8)((UINTN)mVtdUnitInformation[VtdIndex].CapReg.Bits.ND * 2 + 4)) - 1);
ContextEntry->Bits.Present = 1;