From: "wenyi,xie" <xiewenyi2@huawei.com>
To: <devel@edk2.groups.io>, <maciej.rabeda@linux.intel.com>,
<siyuan.fu@intel.com>
Cc: <songdongkuang@huawei.com>, <xiewenyi2@huawei.com>
Subject: [PATCH EDK2 v1 1/1] NetworkPkg/Ip4Dxe:Null-checking before dereference
Date: Sun, 29 Jan 2023 09:14:24 +0800 [thread overview]
Message-ID: <20230129011424.1716624-2-xiewenyi2@huawei.com> (raw)
In-Reply-To: <20230129011424.1716624-1-xiewenyi2@huawei.com>
Null-checking first before a pointer is dereferenced.
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
NetworkPkg/Ip4Dxe/Ip4Config2Nv.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c b/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c
index e0b6a4d4a92f..b96e11bdabba 100644
--- a/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c
+++ b/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c
@@ -397,16 +397,16 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
UINTN DnsCount;
EFI_IPv4_ADDRESS *DnsAddress;
+ if ((IfrNvData == NULL) || (Instance == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
Status = EFI_SUCCESS;
Ip4Config2 = &Instance->Ip4Config2;
Ip4Info = NULL;
DnsAddress = NULL;
GatewaySize = sizeof (EFI_IPv4_ADDRESS);
- if ((IfrNvData == NULL) || (Instance == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
NET_CHECK_SIGNATURE (Instance, IP4_CONFIG2_INSTANCE_SIGNATURE);
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
@@ -571,6 +571,10 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
UINTN DataSize;
EFI_INPUT_KEY Key;
+ if ((Instance == NULL) || (IfrFormNvData == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
Status = EFI_SUCCESS;
Ip4Cfg2 = &Instance->Ip4Config2;
Ip4NvData = &Instance->Ip4NvData;
@@ -581,10 +585,6 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
TimeoutEvent = NULL;
SetAddressEvent = NULL;
- if ((Instance == NULL) || (IfrFormNvData == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
if (IfrFormNvData->Configure != TRUE) {
return EFI_SUCCESS;
}
--
2.20.1.windows.1
prev parent reply other threads:[~2023-01-29 1:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 1:14 [PATCH EDK2 v1 0/1] NetworkPkg/Ip4Dxe:Null-checking before dereference wenyi,xie
2023-01-29 1:14 ` wenyi,xie [this message]
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=20230129011424.1716624-2-xiewenyi2@huawei.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