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.43; helo=mga05.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 5ADFD221ED77E for ; Wed, 20 Dec 2017 23:07:56 -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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2017 23:12:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,434,1508828400"; d="scan'208";a="20066166" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.141]) by orsmga002.jf.intel.com with ESMTP; 20 Dec 2017 23:12:42 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Wang Fan , Ye Ting , Fu Siyuan , Wu Jiaxin Date: Thu, 21 Dec 2017 15:12:40 +0800 Message-Id: <1513840360-12740-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [Patch] MdeModulePkg/SnpDxe: Check the value of Nii->Id before use it directly. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2017 07:07:56 -0000 Nii->Id is the address of the first byte of the identifying structure for this network interface. This is only valid when the network interface is started. When the network interface is not started, this field is set to zero. So, we should check the value of Nii->Id before use it directly. Cc: Wang Fan Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c index 9f61aee..f0257a2 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c @@ -1,9 +1,9 @@ /** @file Implementation of driver entry point and driver binding protocol. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, 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 http://opensource.org/licenses/bsd-license.php @@ -333,10 +333,15 @@ SimpleNetworkDriverStart ( return Status; } DEBUG ((EFI_D_INFO, "Start(): UNDI3.1 found\n")); + if (Nii->Id == 0) { + DEBUG ((EFI_D_NET, "\nUNDI is not started.\n")); + goto NiiError; + } + Pxe = (PXE_UNDI *) (UINTN) (Nii->Id); if (Calc8BitCksum (Pxe, Pxe->hw.Len) != 0) { DEBUG ((EFI_D_NET, "\n!PXE checksum is not correct.\n")); goto NiiError; -- 1.9.5.msysgit.1