public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fu, Siyuan" <siyuan.fu@intel.com>
To: "Wang, Fan" <fan.wang@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wu, Jiaxin" <jiaxin.wu@intel.com>, "Ye, Ting" <ting.ye@intel.com>
Subject: Re: [Patch] MdeModulePkg: Free NET_BUF data after it is sent out to avoid memory leak
Date: Wed, 22 Nov 2017 07:41:02 +0000	[thread overview]
Message-ID: <B1FF2E9001CE9041BD10B825821D5BC58B3E8586@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <1511333741-7060-1-git-send-email-fan.wang@intel.com>

Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>



> -----Original Message-----
> From: Wang, Fan
> Sent: Wednesday, November 22, 2017 2:56 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>; Fu,
> Siyuan <siyuan.fu@intel.com>; Wang, Fan <fan.wang@intel.com>
> Subject: [Patch] MdeModulePkg: Free NET_BUF data after it is sent out to
> avoid memory leak
> 
> When build a DHCP message in function DhcpSendMessage() or
> DhcpRetransmit(),
> a new NET_BUF is created by the library of NetbufFromExt, but it's not
> freed
> after it is sent out. This patch is to fix this memory leak issue.
> 
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wang Fan <fan.wang@intel.com>
> ---
>  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> index 3898223..d90dc34 100644
> --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> @@ -1397,23 +1397,22 @@ DhcpSendMessage (
>      EndPoint.LocalAddr.Addr[0]  = DhcpSb->ClientAddr;
>      UdpIo                       = DhcpSb->LeaseIoPort;
>    }
> 
>    ASSERT (UdpIo != NULL);
> -  NET_GET_REF (Wrap);
> -
> +
>    Status = UdpIoSendDatagram (
>               UdpIo,
>               Wrap,
>               &EndPoint,
>               NULL,
>               DhcpOnPacketSent,
>               DhcpSb
>               );
> 
>    if (EFI_ERROR (Status)) {
> -    NET_PUT_REF (Wrap);
> +    NetbufFree (Wrap);
>      return EFI_ACCESS_DENIED;
>    }
> 
>    return EFI_SUCCESS;
>  }
> @@ -1475,22 +1474,21 @@ DhcpRetransmit (
>      UdpIo                       = DhcpSb->LeaseIoPort;
>    }
> 
>    ASSERT (UdpIo != NULL);
> 
> -  NET_GET_REF (Wrap);
>    Status = UdpIoSendDatagram (
>               UdpIo,
>               Wrap,
>               &EndPoint,
>               NULL,
>               DhcpOnPacketSent,
>               DhcpSb
>               );
> 
>    if (EFI_ERROR (Status)) {
> -    NET_PUT_REF (Wrap);
> +    NetbufFree (Wrap);
>      return EFI_ACCESS_DENIED;
>    }
> 
>    return EFI_SUCCESS;
>  }
> --
> 1.9.5.msysgit.1



  reply	other threads:[~2017-11-22  7:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22  6:55 [Patch] MdeModulePkg: Free NET_BUF data after it is sent out to avoid memory leak fanwang2
2017-11-22  7:41 ` Fu, Siyuan [this message]
2017-11-23  1:15 ` 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=B1FF2E9001CE9041BD10B825821D5BC58B3E8586@SHSMSX103.ccr.corp.intel.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