From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 11AF021EC8D0C for ; Wed, 27 Sep 2017 23:57:31 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2017 00:00:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,448,1500966000"; d="scan'208";a="156995964" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga006.fm.intel.com with ESMTP; 28 Sep 2017 00:00:44 -0700 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Star Zeng , Michael D Kinney , Jiewen Yao Date: Thu, 28 Sep 2017 15:00:39 +0800 Message-Id: <20170928070039.632-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 Subject: [PATCH] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr 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: Thu, 28 Sep 2017 06:57:32 -0000 Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for checking NULL pointer dereference. This commit adds comments to clarify the reason for using ASSERT as the check. Cc: Star Zeng Cc: Michael D Kinney Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- MdeModulePkg/Core/Dxe/Hand/Handle.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c index 2db441725c..344ff1fe02 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c @@ -1175,10 +1175,15 @@ Done: // if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) { // + // According to above logic, if 'Prot' is NULL, then the 'Status' must be + // EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so 'Prot' + // must be not NULL. + // + ASSERT (Prot != NULL); + // // EFI_ALREADY_STARTED is not an error for bus driver. // Return the corresponding protocol interface. // - ASSERT (Prot != NULL); *Interface = Prot->Interface; } else if (Status == EFI_UNSUPPORTED) { // -- 2.12.0.windows.1