diff mbox series

[v2] perf bpf-filter: Return -ENOMEM directly when pfi allocation fails

Message ID 20241113030537.26732-1-hao.ge@linux.dev (mailing list archive)
State Not Applicable
Headers show
Series [v2] perf bpf-filter: Return -ENOMEM directly when pfi allocation fails | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Hao Ge Nov. 13, 2024, 3:05 a.m. UTC
From: Hao Ge <gehao@kylinos.cn>

Directly return -ENOMEM when pfi allocation fails,
instead of performing other operations on pfi.

Fixes: 0fe2b18ddc40 ("perf bpf-filter: Support multiple events properly")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
v2: Replace -1 with -ENOMEM as per Arnaldo's reminder.
    Update title and commit message due to code change
---
 tools/perf/util/bpf-filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Namhyung Kim Nov. 19, 2024, 12:08 a.m. UTC | #1
On Wed, Nov 13, 2024 at 11:05:37AM +0800, Hao Ge wrote:
> From: Hao Ge <gehao@kylinos.cn>
> 
> Directly return -ENOMEM when pfi allocation fails,
> instead of performing other operations on pfi.
> 
> Fixes: 0fe2b18ddc40 ("perf bpf-filter: Support multiple events properly")
> Signed-off-by: Hao Ge <gehao@kylinos.cn>

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

Thanks,
Namhyung

> ---
> v2: Replace -1 with -ENOMEM as per Arnaldo's reminder.
>     Update title and commit message due to code change
> ---
>  tools/perf/util/bpf-filter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/bpf-filter.c b/tools/perf/util/bpf-filter.c
> index e87b6789eb9e..a4fdf6911ec1 100644
> --- a/tools/perf/util/bpf-filter.c
> +++ b/tools/perf/util/bpf-filter.c
> @@ -375,7 +375,7 @@ static int create_idx_hash(struct evsel *evsel, struct perf_bpf_filter_entry *en
>  	pfi = zalloc(sizeof(*pfi));
>  	if (pfi == NULL) {
>  		pr_err("Cannot save pinned filter index\n");
> -		goto err;
> +		return -ENOMEM;
>  	}
>  
>  	pfi->evsel = evsel;
> -- 
> 2.25.1
>
Namhyung Kim Nov. 22, 2024, 10:17 p.m. UTC | #2
On Wed, 13 Nov 2024 11:05:37 +0800, Hao Ge wrote:

> Directly return -ENOMEM when pfi allocation fails,
> instead of performing other operations on pfi.
> 
> 

Applied to perf-tools-next, thanks!

Best regards,
Namhyung
diff mbox series

Patch

diff --git a/tools/perf/util/bpf-filter.c b/tools/perf/util/bpf-filter.c
index e87b6789eb9e..a4fdf6911ec1 100644
--- a/tools/perf/util/bpf-filter.c
+++ b/tools/perf/util/bpf-filter.c
@@ -375,7 +375,7 @@  static int create_idx_hash(struct evsel *evsel, struct perf_bpf_filter_entry *en
 	pfi = zalloc(sizeof(*pfi));
 	if (pfi == NULL) {
 		pr_err("Cannot save pinned filter index\n");
-		goto err;
+		return -ENOMEM;
 	}
 
 	pfi->evsel = evsel;