* [PATCH v1 0/1] NetworkPkg: Fixes to static code analysis hits
@ 2019-11-28 14:46 Maciej Rabeda
2019-11-28 14:46 ` [PATCH v1 1/1] " Maciej Rabeda
0 siblings, 1 reply; 5+ messages in thread
From: Maciej Rabeda @ 2019-11-28 14:46 UTC (permalink / raw)
To: devel
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2334
Introducing fixes to memory leak issues identified by static code analysis
tool.
Maciej Rabeda (1):
NetworkPkg: Fixes to static code analysis hits
NetworkPkg/Dhcp6Dxe/Dhcp6Io.c | 1 +
NetworkPkg/Ip4Dxe/Ip4If.c | 6 +++++-
NetworkPkg/TcpDxe/TcpDispatcher.c | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
--
2.24.0.windows.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/1] NetworkPkg: Fixes to static code analysis hits
2019-11-28 14:46 [PATCH v1 0/1] NetworkPkg: Fixes to static code analysis hits Maciej Rabeda
@ 2019-11-28 14:46 ` Maciej Rabeda
2019-11-28 15:19 ` [edk2-devel] " Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Maciej Rabeda @ 2019-11-28 14:46 UTC (permalink / raw)
To: devel; +Cc: Jiaxin Wu, Siyuan Fu
Introducing fixes to memory leak issues identified by static code analysis
tool.
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Maciej Rabeda <maciej.rabeda@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);
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;
+ }
+
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);
return Status;
}
--
2.24.0.windows.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] NetworkPkg: Fixes to static code analysis hits
2019-11-28 14:46 ` [PATCH v1 1/1] " Maciej Rabeda
@ 2019-11-28 15:19 ` Philippe Mathieu-Daudé
2019-11-29 0:38 ` Siyuan, Fu
2019-11-29 0:54 ` [edk2-devel] " Wu, Jiaxin
2 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-11-28 15:19 UTC (permalink / raw)
To: devel, maciej.rabeda; +Cc: Jiaxin Wu, Siyuan Fu
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.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Signed-off-by: Maciej Rabeda <maciej.rabeda@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 <philmd@redhat.com>
> return Status;
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] NetworkPkg: Fixes to static code analysis hits
2019-11-28 14:46 ` [PATCH v1 1/1] " Maciej Rabeda
2019-11-28 15:19 ` [edk2-devel] " Philippe Mathieu-Daudé
@ 2019-11-29 0:38 ` Siyuan, Fu
2019-11-29 0:54 ` [edk2-devel] " Wu, Jiaxin
2 siblings, 0 replies; 5+ messages in thread
From: Siyuan, Fu @ 2019-11-29 0:38 UTC (permalink / raw)
To: Maciej Rabeda, devel@edk2.groups.io; +Cc: Wu, Jiaxin
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
> -----Original Message-----
> From: Maciej Rabeda <maciej.rabeda@linux.intel.com>
> Sent: 2019年11月28日 22:46
> To: devel@edk2.groups.io
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [PATCH v1 1/1] NetworkPkg: Fixes to static code analysis hits
>
> Introducing fixes to memory leak issues identified by static code analysis
> tool.
>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Signed-off-by: Maciej Rabeda <maciej.rabeda@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);
>
> 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;
>
> + }
>
> +
>
> 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);
>
> return Status;
>
> }
>
>
>
> --
> 2.24.0.windows.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] NetworkPkg: Fixes to static code analysis hits
2019-11-28 14:46 ` [PATCH v1 1/1] " Maciej Rabeda
2019-11-28 15:19 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-11-29 0:38 ` Siyuan, Fu
@ 2019-11-29 0:54 ` Wu, Jiaxin
2 siblings, 0 replies; 5+ messages in thread
From: Wu, Jiaxin @ 2019-11-29 0:54 UTC (permalink / raw)
To: devel@edk2.groups.io, maciej.rabeda@linux.intel.com; +Cc: Fu, Siyuan
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Maciej
> Rabeda
> Sent: Thursday, November 28, 2019 10:46 PM
> To: devel@edk2.groups.io
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [edk2-devel] [PATCH v1 1/1] NetworkPkg: Fixes to static code
> analysis hits
>
> Introducing fixes to memory leak issues identified by static code analysis
> tool.
>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Signed-off-by: Maciej Rabeda <maciej.rabeda@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);
>
> 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;
>
> + }
>
> +
>
> 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);
>
> return Status;
>
> }
>
>
>
> --
> 2.24.0.windows.2
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
>
> View/Reply Online (#51464): https://edk2.groups.io/g/devel/message/51464
> Mute This Topic: https://groups.io/mt/64137254/1787330
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [jiaxin.wu@intel.com]
> -=-=-=-=-=-=
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-29 0:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-28 14:46 [PATCH v1 0/1] NetworkPkg: Fixes to static code analysis hits Maciej Rabeda
2019-11-28 14:46 ` [PATCH v1 1/1] " Maciej Rabeda
2019-11-28 15:19 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-11-29 0:38 ` Siyuan, Fu
2019-11-29 0:54 ` [edk2-devel] " Wu, Jiaxin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox