From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=maggie.chu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 962D4211C6067 for ; Fri, 1 Feb 2019 02:44:11 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2019 02:44:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,548,1539673200"; d="scan'208";a="130715448" Received: from chumaggi-mobl.gar.corp.intel.com ([10.5.245.233]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2019 02:44:09 -0800 From: Maggie Chu To: edk2-devel@lists.01.org Cc: Chao Zhang , Jiewen Yao , Eric Dong Date: Fri, 1 Feb 2019 18:44:05 +0800 Message-Id: <20190201104405.14104-1-maggie.chu@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 Subject: [PATCH] SecurityPkg/OpalPassword: Add NULL pointer check before using it X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 10:44:11 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=1503 A pointer variable should be checked if it is NULL or Valid before using it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Maggie Chu Cc: Chao Zhang Cc: Jiewen Yao Cc: Eric Dong --- SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c index 734c5f06ff..f79f9f7282 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c @@ -436,6 +436,9 @@ BuildOpalDeviceInfoAta ( DevInfoAta = AllocateZeroPool (DevInfoLengthAta); ASSERT (DevInfoAta != NULL); + if (DevInfoAta == NULL) { + return; + } TempDevInfoAta = DevInfoAta; TmpDev = mOpalDriver.DeviceList; @@ -527,6 +530,9 @@ BuildOpalDeviceInfoNvme ( DevInfoNvme = AllocateZeroPool (DevInfoLengthNvme); ASSERT (DevInfoNvme != NULL); + if (DevInfoNvme == NULL) { + return; + } TempDevInfoNvme = DevInfoNvme; TmpDev = mOpalDriver.DeviceList; -- 2.16.2.windows.1