Skip to contentSkip to conversation

perf unwind-libunwind: Add malloc() failure handling

PATCH Applied [email protected] 2 participants 3 messages Jun 19, 2024 – Jun 26, 2024 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf unwind-libunwind: Add malloc() failure handling

From: Yunseong Kim <[email protected]>

Add malloc() failure handling in unread_unwind_spec_debug_frame(). This make caller find_proc_info() works well when the allocation failure.

---
 tools/perf/util/unwind-libunwind-local.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/util/unwind-libunwind-local.c +5 -0
index cde267ea3e99..a424eae6d308 100644
@@ -390,6 +390,11 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
 			char *debuglink = malloc(PATH_MAX);
 			int ret = 0;
 
+			if (debuglink == NULL) {
+				pr_err("unwind: Can't read unwind spec debug frame.\n");
+				return -ENOMEM;
+			}
+
 			ret = dso__read_binary_type_filename(
 				dso, DSO_BINARY_TYPE__DEBUGLINK,
 				machine->root_dir, debuglink, PATH_MAX);
Signature · 1 line
2.45.2
maintainer Applied
#1 lore raw
Quoted 4 lines · On Thu, 20 Jun 2024 05:42:12 +0900, [email protected] wrote:

Add malloc() failure handling in unread_unwind_spec_debug_frame(). This make caller find_proc_info() works well when the allocation failure.

Applied to perf-tools-next, thanks!

Best regards,
Namhyung

#2 lore raw

Hi Namhyung,

Quoted 10 lines · Namhyung Kim
Quoted 8 lines · On Thu, 20 Jun 2024 05:42:12 +0900, [email protected] wrote:

This patch resolve following warning.

tools/perf/util/evsel.c:1620:9: error: result of comparison of constant -1 with expression of type 'char' is always false
-Werror,-Wtautological-constant-out-of-range-compare
1620 | if (c == -1)
| ~ ^ ~~

Quoted 3 lines
Quoted 1 line

[...]

Applied to perf-tools-next, thanks!

Thank you!

Quoted 9 lines
Quoted 4 lines

Add malloc() failure handling in unread_unwind_spec_debug_frame(). This make caller find_proc_info() works well when the allocation failure.

Applied to perf-tools-next, thanks!

Best regards,
Namhyung

Thank you for applying my patch set.

I've been looking up the feedback you provided earlier and analyzing it further.

Next time, I will strive to send a more meaningful patch set.

Warm regards,
Yunseong Kim