* [PATCH] perf tools: Call closedir to release the resource before we return
@ 2019-10-25 3:16 Hewenliang
2019-10-25 7:39 ` Jiri Olsa
2019-10-25 12:02 ` Arnaldo Carvalho de Melo
0 siblings, 2 replies; 3+ messages in thread
From: Hewenliang @ 2019-10-25 3:16 UTC (permalink / raw)
To: peterz, jolsa, acme, mark.rutland, alexander.shishkin, namhyung,
ilubashe, ak, linux-kernel, hewenliang4
Cc: hushiyuan, linfeilong
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf tools: Call closedir to release the resource before we return
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
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2019-10-25 7:39 UTC (permalink / raw)
To: Hewenliang
Cc: peterz, acme, mark.rutland, alexander.shishkin, namhyung,
ilubashe, ak, linux-kernel, hushiyuan, linfeilong
On Thu, Oct 24, 2019 at 11:16:05PM -0400, Hewenliang wrote:
> 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>
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
> ---
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf tools: Call closedir to release the resource before we return
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
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-10-25 12:02 UTC (permalink / raw)
To: Hewenliang
Cc: peterz, jolsa, mark.rutland, alexander.shishkin, namhyung,
ilubashe, ak, linux-kernel, hushiyuan, linfeilong
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-25 12:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.