Reviewed-by: jiewen....@intel.com > -----Original Message----- > From: Wu, Hao A > Sent: Thursday, June 30, 2016 9:57 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A <hao.a...@intel.com>; Yao, Jiewen <jiewen....@intel.com> > Subject: [PATCH v2] IntelFsp2WrapperPkg: Add error handling for possible > NULL ptr dereference > > Possible NULL pointer dereference for FspmHeaderPtr/FspsHeaderPtr in > module FspmWrapperPeim/FspsWrapperPeim. > > Add error handling codes to avoid this issue. > > Cc: Jiewen Yao <jiewen....@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu <hao.a...@intel.com> > --- > IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c | 5 +++++ > IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c | 5 +++++ > 2 files changed, 10 insertions(+) > > diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c > b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c > index 6144ad7..c98513e 100644 > --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c > +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c > @@ -68,6 +68,11 @@ PeiFspMemoryInit ( > // Copy default FSP-M UPD data from Flash > // > FspmHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 > (PcdFspmBaseAddress)); > + DEBUG ((DEBUG_INFO, "FspmHeaderPtr - 0x%x\n", FspmHeaderPtr)); > + if (FspmHeaderPtr == NULL) { > + return EFI_DEVICE_ERROR; > + } > + > FspmUpdDataPtr = (FSPM_UPD_COMMON *)AllocateZeroPool > ((UINTN)FspmHeaderPtr->CfgRegionSize); > ASSERT (FspmUpdDataPtr != NULL); > SourceData = (UINTN *)((UINTN)FspmHeaderPtr->ImageBase + > (UINTN)FspmHeaderPtr->CfgRegionOffset); > diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c > b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c > index 7a65ad7..c923690 100644 > --- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c > +++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c > @@ -241,6 +241,11 @@ PeiMemoryDiscoveredNotify ( > // Copy default FSP-S UPD data from Flash > // > FspsHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 > (PcdFspsBaseAddress)); > + DEBUG ((DEBUG_INFO, "FspsHeaderPtr - 0x%x\n", FspsHeaderPtr)); > + if (FspsHeaderPtr == NULL) { > + return EFI_DEVICE_ERROR; > + } > + > FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool > ((UINTN)FspsHeaderPtr->CfgRegionSize); > ASSERT (FspsUpdDataPtr != NULL); > SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + > (UINTN)FspsHeaderPtr->CfgRegionOffset); > -- > 1.9.5.msysgit.0
_______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel