public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Hewenliang <hewenliang4@huawei.com>
Cc: peterz@infradead.org, jolsa@redhat.com, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, namhyung@kernel.org,
	ilubashe@akamai.com, ak@linux.intel.com,
	linux-kernel@vger.kernel.org, hushiyuan@huawei.com,
	linfeilong@huawei.com
Subject: Re: [PATCH] perf tools: Call closedir to release the resource before we return
Date: Fri, 25 Oct 2019 09:02:48 -0300	[thread overview]
Message-ID: <20191025120248.GA23511@kernel.org> (raw)
In-Reply-To: <20191025031605.23658-1-hewenliang4@huawei.com>

Em Thu, Oct 24, 2019 at 11:16:05PM -0400, Hewenliang escreveu:
> We should close the directory on pattern failure before the return
> of rm_rf_depth_pat.
> 
> Fixes: cdb6b0235f170 ("perf tools: Add pattern name checking to rm_rf")
> Signed-off-by: Hewenliang <hewenliang4@huawei.com>

I've already applied:

commit 6080728ff8e9c9116e52e6f840152356ac2fea56
Author: Yunfeng Ye <yeyunfeng@huawei.com>
Date:   Tue Oct 15 16:30:08 2019 +0800

    perf tools: Fix resource leak of closedir() on the error paths
    
    Both build_mem_topology() and rm_rf_depth_pat() have resource leaks of
    closedir() on the error paths.
    
    Fix this by calling closedir() before function returns.
    
    Fixes: e2091cedd51b ("perf tools: Add MEM_TOPOLOGY feature to perf data file")
    Fixes: cdb6b0235f17 ("perf tools: Add pattern name checking to rm_rf")
    Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
    Acked-by: Jiri Olsa <jolsa@kernel.org>

[acme@quaco perf]$ git tag --contains 6080728ff8e9c9116e52e6f840152356ac2fea56
perf-urgent-for-mingo-5.4-20191017
[acme@quaco perf]$ 

It is already in tip/perf/urgent, should get to Linus soon.

- Arnaldo

> ---
>  tools/perf/util/util.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 5eda6e19c947..1aadca8c43f3 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -154,8 +154,10 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat)
>  		if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
>  			continue;
>  
> -		if (!match_pat(d->d_name, pat))
> +		if (!match_pat(d->d_name, pat)) {
> +			closedir(dir);
>  			return -2;
> +		}
>  
>  		scnprintf(namebuf, sizeof(namebuf), "%s/%s",
>  			  path, d->d_name);
> -- 
> 2.19.1

-- 

- Arnaldo

      parent reply	other threads:[~2019-10-25 12:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  3:16 [PATCH] perf tools: Call closedir to release the resource before we return Hewenliang
2019-10-25  7:39 ` Jiri Olsa
2019-10-25 12:02 ` Arnaldo Carvalho de Melo [this message]

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=20191025120248.GA23511@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=hewenliang4@huawei.com \
    --cc=hushiyuan@huawei.com \
    --cc=ilubashe@akamai.com \
    --cc=jolsa@redhat.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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