From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: devel@edk2.groups.io, maciej.rabeda@linux.intel.com
Cc: Jiaxin Wu <jiaxin.wu@intel.com>, Siyuan Fu <siyuan.fu@intel.com>
Subject: Re: [edk2-devel] [PATCH v1 1/1] NetworkPkg: Fixes to static code analysis hits
Date: Thu, 28 Nov 2019 16:19:41 +0100 [thread overview]
Message-ID: <84a623df-467a-275e-0921-31d05ff723b5@redhat.com> (raw)
In-Reply-To: <20191128144606.2040-2-maciej.rabeda@linux.intel.com>
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;
> }
>
>
next prev parent reply other threads:[~2019-11-28 15:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Philippe Mathieu-Daudé [this message]
2019-11-29 0:38 ` Siyuan, Fu
2019-11-29 0:54 ` [edk2-devel] " 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=84a623df-467a-275e-0921-31d05ff723b5@redhat.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