From d72d8561fbe03a64e01c2ad57a93777de4b9ae2f Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Thu, 14 Feb 2019 14:53:14 +0800 Subject: [PATCH] SecurityPkg/OpalPassword: Add NULL pointer check before using it https://bugzilla.tianocore.org/show_bug.cgi?id=1503 A pointer variable should be checked if it is NULL or Valid before using it. Cc: Chao Zhang Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Maggie Chu Reviewed-by: Eric Dong --- SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c index 734c5f06ff..b5317d82b8 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c @@ -2,7 +2,7 @@ Entrypoint of Opal UEFI Driver and contains all the logic to register for new Opal device instances. -Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -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.39.2