Skip to contentSkip to conversation

perf bpf-filter: Return -1 directly when pfi allocation fails

PATCH Superseded Hao Ge 3 participants 5 messages Nov 12, 2024 – Nov 22, 2024

Subsystems (2)
lore
Share & tools
lore

Hao Ge

author
#0 lore raw

PATCH 1/1 perf bpf-filter: Return -1 directly when pfi allocation fails

From: Hao Ge <[email protected]>

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

Fixes 0fe2b18ddc40 ("perf bpf-filter: Support multiple events properly")
---
 tools/perf/util/bpf-filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/bpf-filter.c +1 -1
index e87b6789eb9e..34c8bf7e469e 100644
@@ -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 -1;
 	}
 
 	pfi->evsel = evsel;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Hao Ge

From: Hao Ge <[email protected]>

Directly return -1 when pfi allocation fails,

The convention for this function is to return -errno, so please resubmit returning -ENOMEM.

- Arnaldo

Quoted 23 lines

instead of performing other operations on pfi.

Fixes 0fe2b18ddc40 ("perf bpf-filter: Support multiple events properly")
---
 tools/perf/util/bpf-filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/bpf-filter.c +1 -1
index e87b6789eb9e..34c8bf7e469e 100644
@@ -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 -1;
 	}
 
 	pfi->evsel = evsel;
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH v2 1/1 perf bpf-filter: Return -ENOMEM directly when pfi allocation fails

From: Hao Ge <[email protected]>

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

Fixes 0fe2b18ddc40 ("perf bpf-filter: Support multiple events properly")

---
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(-)
tools/perf/util/bpf-filter.c +1 -1
index e87b6789eb9e..a4fdf6911ec1 100644
@@ -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;
Signature · 1 line
2.25.1
maintainer Acked-by on v2 1/1
#3 lore raw

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

Quoted 7 lines · Hao Ge

From: Hao Ge <[email protected]>

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

Fixes 0fe2b18ddc40 ("perf bpf-filter: Support multiple events properly")

Thanks,
Namhyung

Quoted 23 lines

---
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(-)
tools/perf/util/bpf-filter.c +1 -1
index e87b6789eb9e..a4fdf6911ec1 100644
@@ -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;
Signature · 1 line
2.25.1
maintainer Applied
#4 lore raw

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

In reply to Hao Ge
Quoted 4 lines · Hao Ge

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

Applied to perf-tools-next, thanks!

Best regards,
Namhyung