Patchwork perf tools: return errcode in cs_etm__process_auxtrace_info

login
register
mail settings
Submitter YueHaibing
Date March 15, 2019, 2:26 a.m.
Message ID <20190315022649.17848-1-yuehaibing@huawei.com>
Download mbox | patch
Permalink /patch/749227/
State New
Headers show

Comments

YueHaibing - March 15, 2019, 2:26 a.m.
From: YueHaibing <yuehaibing@huawei.com>

'err' is set in err path, but it's not returned to callers.
Also fix a pass zero to PTR_ERR issue.

Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 tools/perf/util/cs-etm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Mathieu Poirier - March 18, 2019, 5:13 p.m.
Good day Yue,

On Thu, 14 Mar 2019 at 20:28, Yue Haibing <yuehaibing@huawei.com> wrote:
>
> From: YueHaibing <yuehaibing@huawei.com>
>
> 'err' is set in err path, but it's not returned to callers.
> Also fix a pass zero to PTR_ERR issue.
>
> Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  tools/perf/util/cs-etm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index 1108049..111f33c 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -1908,7 +1908,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>
>                 /* Something went wrong, no need to continue */
>                 if (!inode) {
> -                       err = PTR_ERR(inode);
> +                       err = -ENOMEM;

Good catch.

>                         goto err_free_metadata;
>                 }
>
> @@ -2023,5 +2023,5 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>  err_free_hdr:
>         zfree(&hdr);
>
> -       return -EINVAL;
> +       return err;

If we do that we need to set 'err' to an error code here [1] and here
[2].  Do you think you could fix this and roll another version of your
patch?

[1]. https://elixir.bootlin.com/linux/v5.1-rc1/source/tools/perf/util/cs-etm.c#L1967
[2]. https://elixir.bootlin.com/linux/v5.1-rc1/source/tools/perf/util/cs-etm.c#L1981
>  }
> --
> 2.7.0
>
>
Arnaldo Carvalho de Melo - March 18, 2019, 5:15 p.m.
Em Fri, Mar 15, 2019 at 10:26:49AM +0800, Yue Haibing escreveu:
> From: YueHaibing <yuehaibing@huawei.com>
> 
> 'err' is set in err path, but it's not returned to callers.
> Also fix a pass zero to PTR_ERR issue.

Next time please submit two patches, one for the PTR_ERR and another for
not throwing away the err = -E!INVAL and returning just -EINVAL, I'm
doing it this time.
 
 - Arnaldo

> Fixes: cd8bfd8c973e ("perf tools: Add processing of coresight metadata")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  tools/perf/util/cs-etm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index 1108049..111f33c 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -1908,7 +1908,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>  
>  		/* Something went wrong, no need to continue */
>  		if (!inode) {
> -			err = PTR_ERR(inode);
> +			err = -ENOMEM;
>  			goto err_free_metadata;
>  		}
>  
> @@ -2023,5 +2023,5 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>  err_free_hdr:
>  	zfree(&hdr);
>  
> -	return -EINVAL;
> +	return err;
>  }
> -- 
> 2.7.0
>

Patch

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 1108049..111f33c 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -1908,7 +1908,7 @@  int cs_etm__process_auxtrace_info(union perf_event *event,
 
 		/* Something went wrong, no need to continue */
 		if (!inode) {
-			err = PTR_ERR(inode);
+			err = -ENOMEM;
 			goto err_free_metadata;
 		}
 
@@ -2023,5 +2023,5 @@  int cs_etm__process_auxtrace_info(union perf_event *event,
 err_free_hdr:
 	zfree(&hdr);
 
-	return -EINVAL;
+	return err;
 }