lkml.org 
[lkml]   [2019]   [Oct]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] perf tools: Call closedir to release the resource before we return
Date
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
\
 
 \ /
  Last update: 2019-10-25 05:17    [W:0.037 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site