DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
To: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>, david.marchand@6wind.com
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3] eal/linuxapp: fix resource leak
Date: Thu, 30 Jun 2016 14:31:24 +0100	[thread overview]
Message-ID: <3f3b0684-4834-b855-bc8a-e386d2ac7ff1@intel.com> (raw)
In-Reply-To: <1466614235-121524-1-git-send-email-danielx.t.mrzyglod@intel.com>

On 22/06/2016 17:50, Daniel Mrzyglod wrote:
> This patch fix all cases to do proper handle all munmap if pointer
> of hugepage is not NULL which prohibits resource leak.

I would reword the above commit to something like:

Current code does not munmap 'hugepage' mapping (hugepage info file) on 
function
exit, leaking resources.

> Coverity issue: 97920
> Fixes: b6a468ad41d5 ("memory: add --socket-mem option")
>
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
> ---
>   lib/librte_eal/linuxapp/eal/eal_memory.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 9251a5b..9b0d39a 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -1051,7 +1051,7 @@ int
>   rte_eal_hugepage_init(void)
>   {
>   	struct rte_mem_config *mcfg;
> -	struct hugepage_file *hugepage, *tmp_hp = NULL;
> +	struct hugepage_file *hugepage = NULL, *tmp_hp = NULL;
>   	struct hugepage_info used_hp[MAX_HUGEPAGE_SIZES];
>   
>   	uint64_t memory[RTE_MAX_NUMA_NODES];
> @@ -1367,13 +1367,15 @@ rte_eal_hugepage_init(void)
>   			"of memory.\n",
>   			i, nr_hugefiles, RTE_STR(CONFIG_RTE_MAX_MEMSEG),
>   			RTE_MAX_MEMSEG);
> -		return -ENOMEM;
> +		goto fail;
>   	}
>   

I missed this but we should also munmap 'hugepage' on successful 
function exit.

Sergio

>   	return 0;
>   
>   fail:
>   	free(tmp_hp);
> +	if (hugepage != NULL)
> +		munmap(hugepage, nr_hugefiles * sizeof(struct hugepage_file));
>   	return -1;
>   }
>   

  reply	other threads:[~2016-06-30 13:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 16:01 [dpdk-dev] [PATCH] " Daniel Mrzyglod
2016-05-12  7:55 ` Sergio Gonzalez Monroy
2016-05-13 10:28   ` Thomas Monjalon
2016-05-12  9:12 ` [dpdk-dev] [PATCH v2] " Daniel Mrzyglod
2016-06-20  9:33   ` Thomas Monjalon
2016-06-22 16:50 ` [dpdk-dev] [PATCH v3] " Daniel Mrzyglod
2016-06-30 13:31   ` Sergio Gonzalez Monroy [this message]
2016-07-06 10:44 ` [dpdk-dev] [PATCH v4] " Daniel Mrzyglod
2016-07-06 10:48   ` Sergio Gonzalez Monroy
2016-07-10 13:29     ` Thomas Monjalon

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-all 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=3f3b0684-4834-b855-bc8a-e386d2ac7ff1@intel.com \
    --to=sergio.gonzalez.monroy@intel.com \
    --cc=danielx.t.mrzyglod@intel.com \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    /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;
as well as URLs for NNTP newsgroup(s).