[edk2] [Patch] MdeModulePkg: Update IP4 driver to check for NULL pointer before using.

Fu Siyuan posted 1 patch 5 years, 9 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
[edk2] [Patch] MdeModulePkg: Update IP4 driver to check for NULL pointer before using.
Posted by Fu Siyuan 5 years, 9 months ago
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 5a9d828703..6a26143e30 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -1048,11 +1048,8 @@ Ip4Groups (
   // is decreamented each time an address is removed..
   //
   for (Index = IpInstance->GroupCount; Index > 0 ; Index--) {
-    Group = 0;  	
-    if(IpInstance->Groups != NULL) {
-  	  Group = IpInstance->Groups[Index - 1];
-  	}
-  	
+    ASSERT (IpInstance->Groups != NULL);
+    Group = IpInstance->Groups[Index - 1];
     if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) {
       if (EFI_ERROR (Ip4LeaveGroup (IpInstance, NTOHL (Group)))) {
         return EFI_DEVICE_ERROR;
-- 
2.13.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] MdeModulePkg: Update IP4 driver to check for NULL pointer before using.
Posted by Wu, Jiaxin 5 years, 9 months ago
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>


> -----Original Message-----
> From: Fu, Siyuan
> Sent: Wednesday, June 27, 2018 9:19 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch] MdeModulePkg: Update IP4 driver to check for NULL
> pointer before using.
> 
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
> ---
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> index 5a9d828703..6a26143e30 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> @@ -1048,11 +1048,8 @@ Ip4Groups (
>    // is decreamented each time an address is removed..
>    //
>    for (Index = IpInstance->GroupCount; Index > 0 ; Index--) {
> -    Group = 0;
> -    if(IpInstance->Groups != NULL) {
> -  	  Group = IpInstance->Groups[Index - 1];
> -  	}
> -
> +    ASSERT (IpInstance->Groups != NULL);
> +    Group = IpInstance->Groups[Index - 1];
>      if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) {
>        if (EFI_ERROR (Ip4LeaveGroup (IpInstance, NTOHL (Group)))) {
>          return EFI_DEVICE_ERROR;
> --
> 2.13.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel