diff mbox series

[v2,2/2] perf cs-etm: return errcode in cs_etm__process_auxtrace_info()

Message ID 20190321023122.21332-3-yuehaibing@huawei.com (mailing list archive)
State Mainlined
Commit 6285bd151b95aa28d6de9b8b9249702681f059d2
Headers show
Series minor fixes for perf cs-etm | expand

Commit Message

Yue Haibing March 21, 2019, 2:31 a.m. UTC
From: YueHaibing <yuehaibing@huawei.com>

'err' is set in err path, but it's not returned to callers.
Don't always return -EINVAL, return err.

Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 tools/perf/util/cs-etm.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Mathieu Poirier March 21, 2019, 4:44 p.m. UTC | #1
On Wed, 20 Mar 2019 at 20:32, Yue Haibing <yuehaibing@huawei.com> wrote:
>
> From: YueHaibing <yuehaibing@huawei.com>
>
> 'err' is set in err path, but it's not returned to callers.
> Don't always return -EINVAL, return err.
>
> Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  tools/perf/util/cs-etm.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index fd7f1da..2cc773a 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -1965,8 +1965,10 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>         session->auxtrace = &etm->auxtrace;
>
>         etm->unknown_thread = thread__new(999999999, 999999999);
> -       if (!etm->unknown_thread)
> +       if (!etm->unknown_thread) {
> +               err = -ENOMEM;
>                 goto err_free_queues;
> +       }
>
>         /*
>          * Initialize list node so that at thread__zput() we can avoid
> @@ -1978,8 +1980,10 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>         if (err)
>                 goto err_delete_thread;
>
> -       if (thread__init_map_groups(etm->unknown_thread, etm->machine))
> +       if (thread__init_map_groups(etm->unknown_thread, etm->machine)) {
> +               err = -ENOMEM;
>                 goto err_delete_thread;
> +       }
>
>         if (dump_trace) {
>                 cs_etm__print_auxtrace_info(auxtrace_info->priv, num_cpu);
> @@ -2023,5 +2027,5 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>  err_free_hdr:
>         zfree(&hdr);
>
> -       return -EINVAL;
> +       return err;
>  }
> --
> 2.7.0

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Same here Arnaldo, please consider.

>
>
diff mbox series

Patch

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index fd7f1da..2cc773a 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -1965,8 +1965,10 @@  int cs_etm__process_auxtrace_info(union perf_event *event,
 	session->auxtrace = &etm->auxtrace;
 
 	etm->unknown_thread = thread__new(999999999, 999999999);
-	if (!etm->unknown_thread)
+	if (!etm->unknown_thread) {
+		err = -ENOMEM;
 		goto err_free_queues;
+	}
 
 	/*
 	 * Initialize list node so that at thread__zput() we can avoid
@@ -1978,8 +1980,10 @@  int cs_etm__process_auxtrace_info(union perf_event *event,
 	if (err)
 		goto err_delete_thread;
 
-	if (thread__init_map_groups(etm->unknown_thread, etm->machine))
+	if (thread__init_map_groups(etm->unknown_thread, etm->machine)) {
+		err = -ENOMEM;
 		goto err_delete_thread;
+	}
 
 	if (dump_trace) {
 		cs_etm__print_auxtrace_info(auxtrace_info->priv, num_cpu);
@@ -2023,5 +2027,5 @@  int cs_etm__process_auxtrace_info(union perf_event *event,
 err_free_hdr:
 	zfree(&hdr);
 
-	return -EINVAL;
+	return err;
 }