public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jiaxin Wu <jiaxin.wu@intel.com>
To: edk2-devel@lists.01.org
Cc: Wang Fan <fan.wang@intel.com>, Ye Ting <ting.ye@intel.com>,
	Fu Siyuan <siyuan.fu@intel.com>, Wu Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch] MdeModulePkg/SnpDxe: Check the value of Nii->Id before use it directly.
Date: Thu, 21 Dec 2017 15:12:40 +0800	[thread overview]
Message-ID: <1513840360-12740-1-git-send-email-jiaxin.wu@intel.com> (raw)

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 <fan.wang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 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.<BR>
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
 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



             reply	other threads:[~2017-12-21  7:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21  7:12 Jiaxin Wu [this message]
2017-12-21  7:39 ` [Patch] MdeModulePkg/SnpDxe: Check the value of Nii->Id before use it directly Fu, Siyuan
2017-12-21  7:59   ` Wu, Jiaxin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1513840360-12740-1-git-send-email-jiaxin.wu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox