On 11/28/19 3:46 PM, Maciej Rabeda via Groups.Io wrote:
Introducing fixes to memory leak issues identified by static code analysis
tool.

Cc: Jiaxin Wu <jiaxin...@intel.com>
Cc: Siyuan Fu <siyuan...@intel.com>
Signed-off-by: Maciej Rabeda <maciej.rab...@linux.intel.com>
---
  NetworkPkg/Dhcp6Dxe/Dhcp6Io.c     | 1 +
  NetworkPkg/Ip4Dxe/Ip4If.c         | 6 +++++-
  NetworkPkg/TcpDxe/TcpDispatcher.c | 1 +
  3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
index 4f8393cb36ce..613b42149cc1 100644
--- a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
@@ -203,6 +203,7 @@ Dhcp6EnqueueRetry (
      //
      // Unexpected message type.
      //
+    FreePool(TxCb);

OK.

      return EFI_DEVICE_ERROR;
    }
diff --git a/NetworkPkg/Ip4Dxe/Ip4If.c b/NetworkPkg/Ip4Dxe/Ip4If.c
index 53a333037f94..348f2e076aed 100644
--- a/NetworkPkg/Ip4Dxe/Ip4If.c
+++ b/NetworkPkg/Ip4Dxe/Ip4If.c
@@ -491,9 +491,13 @@ Ip4CreateInterface (
    IP4_INTERFACE             *Interface;
    EFI_SIMPLE_NETWORK_MODE   SnpMode;
+ if (Mnp == NULL) {
+    return NULL;
+  }

You are fixing existing code, so this is OK.
However I wonder why not use:

     ASSERT (Mnp != NULL);

+
    Interface = AllocatePool (sizeof (IP4_INTERFACE));
- if ((Interface == NULL) || (Mnp == NULL)) {
+  if (Interface == NULL) {
      return NULL;
    }
diff --git a/NetworkPkg/TcpDxe/TcpDispatcher.c b/NetworkPkg/TcpDxe/TcpDispatcher.c
index 86beaf8cc513..9ae08ccc1c56 100644
--- a/NetworkPkg/TcpDxe/TcpDispatcher.c
+++ b/NetworkPkg/TcpDxe/TcpDispatcher.c
@@ -390,6 +390,7 @@ TcpAttachPcb (
                    );
    if (EFI_ERROR (Status)) {
      IpIoRemoveIp (IpIo, Tcb->IpInfo);
+    FreePool (Tcb);

OK.

Reviewed-by: Philippe Mathieu-Daude <phi...@redhat.com>

      return Status;
    }


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#51472): https://edk2.groups.io/g/devel/message/51472
Mute This Topic: https://groups.io/mt/64137254/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to