Reviewed-by: Giri P Mudusuru <[email protected]>
> -----Original Message----- > From: edk2-devel [mailto:[email protected]] On Behalf Of > Hao Wu > Sent: Wednesday, June 29, 2016 6:57 PM > To: [email protected] > Cc: Wu, Hao A <[email protected]>; Yao, Jiewen <[email protected]> > Subject: [edk2] [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 <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu <[email protected]> > --- > 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 > [email protected] > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

