From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 24CDC21E1B74F for ; Thu, 21 Sep 2017 20:44:54 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2017 20:48:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,426,1500966000"; d="scan'208";a="902788906" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 21 Sep 2017 20:48:01 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Sep 2017 20:48:01 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Sep 2017 20:48:01 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.159]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Fri, 22 Sep 2017 11:47:59 +0800 From: "Wu, Hao A" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Dong, Eric" Thread-Topic: [patch] MdeModulePkg/SetupBrowser:Add NULL check before using a pointer Thread-Index: AQHTM0YWmsPxDLf3FkaX4EZ2ea3LNaLARIjQ Date: Fri, 22 Sep 2017 03:47:58 +0000 Message-ID: References: <1506045402-318760-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1506045402-318760-1-git-send-email-dandan.bi@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdeModulePkg/SetupBrowser:Add NULL check before using a pointer 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: Fri, 22 Sep 2017 03:44:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: Bi, Dandan > Sent: Friday, September 22, 2017 9:57 AM > To: edk2-devel@lists.01.org > Cc: Dong, Eric; Wu, Hao A > Subject: [patch] MdeModulePkg/SetupBrowser:Add NULL check before using a > pointer >=20 > Add NULL pointer check before using a pointer to avoid possible > NULL pointer dereference. >=20 > Cc: Eric Dong > Cc: Hao Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi > --- > MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > index 48beeb6..c2cfa5c 100644 > --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c > @@ -1484,11 +1484,13 @@ BufferToValue ( > // > // Other type of Questions > // > if (Question->QuestionReferToBitField) { > Buffer =3D (UINT8 *)AllocateZeroPool (Question->StorageWidth); > - ASSERT (Buffer !=3D NULL); > + if (Buffer =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > Dst =3D Buffer; > } else { > Dst =3D (UINT8 *) &Question->HiiValue.Value; > } > } > @@ -1546,15 +1548,13 @@ BufferToValue ( > } > } >=20 > *StringPtr =3D TempChar; >=20 > - if (Question->QuestionReferToBitField) { > + if (Buffer !=3D NULL && Question->QuestionReferToBitField) { > GetBitsQuestionValue (Question, Buffer); > - if (Buffer !=3D NULL) { > - FreePool (Buffer); > - } > + FreePool (Buffer); > } >=20 > return Status; > } >=20 > -- > 1.9.5.msysgit.1