From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7286D21E2BE4E for ; Sun, 27 Aug 2017 20:14:52 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP; 27 Aug 2017 20:17:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,439,1498546800"; d="scan'208";a="1008217971" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 27 Aug 2017 20:17:31 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 27 Aug 2017 20:17:30 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 27 Aug 2017 20:17:30 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.117]) with mapi id 14.03.0319.002; Mon, 28 Aug 2017 11:17:28 +0800 From: "Dong, Eric" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [patch] IntelFrameworkModulePkg/LegacyBootMaintUiLib: Add NULL pointer check Thread-Index: AQHTHU4bKpYIvY/u90ycx/Ein1slvqKZHaNw Date: Mon, 28 Aug 2017 03:17:28 +0000 Message-ID: References: <1503629916-306840-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1503629916-306840-1-git-send-email-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] IntelFrameworkModulePkg/LegacyBootMaintUiLib: Add NULL pointer check X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Aug 2017 03:14:52 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: Bi, Dandan=20 Sent: Friday, August 25, 2017 10:59 AM To: edk2-devel@lists.01.org Cc: Dong, Eric ; Gao, Liming Subject: [patch] IntelFrameworkModulePkg/LegacyBootMaintUiLib: Add NULL poi= nter check mLegacyBootOptionPrivate pointer is initialized in Constructor function wit= h if condition check, but it's used in Destructor function directly without= any check. Now add the NULL pointer check. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c | 4 = ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBoo= tMaintUi.c b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBoo= tMaintUi.c index 740c95c..a4828b7 100644 --- a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintU= i.c +++ b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMai +++ ntUi.c @@ -13,11 +13,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. **/ =20 =20 #include "LegacyBootMaintUi.h" =20 -LEGACY_BOOT_OPTION_CALLBACK_DATA *mLegacyBootOptionPrivate; +LEGACY_BOOT_OPTION_CALLBACK_DATA *mLegacyBootOptionPrivate =3D NULL; EFI_GUID mLegacyBootOptionGuid =3D LEGACY_BOOT_OPTION_FORMSET_GUID; CHAR16 mLegacyBootStorageName[] =3D L"LegacyBootData"; BBS_TYPE mBbsType[] =3D {BBS_FLOPPY, BBS_HARDDISK, BBS_CDROM, BBS_EMBED_N= ETWORK, BBS_BEV_DEVICE, BBS_UNKNOWN}; BOOLEAN mFirstEnterLegacyForm =3D FALSE; =20 @@ -1484,11 +1484,11 @@ LegacyBootMaintUiLibDestructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; =20 - if (mLegacyBootOptionPrivate->DriverHandle !=3D NULL) { + if (mLegacyBootOptionPrivate !=3D NULL &&=20 + mLegacyBootOptionPrivate->DriverHandle !=3D NULL) { Status =3D gBS->UninstallMultipleProtocolInterfaces ( mLegacyBootOptionPrivate->DriverHandle, &gEfiDevicePathProtocolGuid, &mLegacyBootOptionHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, -- 1.9.5.msysgit.1