[PATCH] perf sched timehist: Fix missing free of session in perf_sched__timehist()

Yang Jihong posted 1 patch 1 year, 4 months ago
tools/perf/builtin-sched.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] perf sched timehist: Fix missing free of session in perf_sched__timehist()
Posted by Yang Jihong 1 year, 4 months ago
When perf_time__parse_str() fails in perf_sched__timehist(),
need to free session that was previously created, fix it.

Fixes: 853b74071110 ("perf sched timehist: Add option to specify time window of interest")
Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
---
 tools/perf/builtin-sched.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 8750b5f2d49b..928b9041535d 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -3121,7 +3121,8 @@ static int perf_sched__timehist(struct perf_sched *sched)
 
 	if (perf_time__parse_str(&sched->ptime, sched->time_str) != 0) {
 		pr_err("Invalid time string\n");
-		return -EINVAL;
+		err = -EINVAL;
+		goto out;
 	}
 
 	if (timehist_check_attr(sched, evlist) != 0)
-- 
2.25.1
Re: [PATCH] perf sched timehist: Fix missing free of session in perf_sched__timehist()
Posted by Namhyung Kim 1 year, 4 months ago
On Tue, Aug 06, 2024 at 10:35:33AM +0800, Yang Jihong wrote:
> When perf_time__parse_str() fails in perf_sched__timehist(),
> need to free session that was previously created, fix it.
> 
> Fixes: 853b74071110 ("perf sched timehist: Add option to specify time window of interest")
> Signed-off-by: Yang Jihong <yangjihong@bytedance.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/perf/builtin-sched.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 8750b5f2d49b..928b9041535d 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -3121,7 +3121,8 @@ static int perf_sched__timehist(struct perf_sched *sched)
>  
>  	if (perf_time__parse_str(&sched->ptime, sched->time_str) != 0) {
>  		pr_err("Invalid time string\n");
> -		return -EINVAL;
> +		err = -EINVAL;
> +		goto out;
>  	}
>  
>  	if (timehist_check_attr(sched, evlist) != 0)
> -- 
> 2.25.1
>