[PATCH] perf unwind-libunwind: Add malloc() failure handling
From: yskelg
Date: Wed Jun 19 2024 - 16:42:51 EST
From: Yunseong Kim <yskelg@xxxxxxxxx>
Add malloc() failure handling in unread_unwind_spec_debug_frame().
This make caller find_proc_info() works well when the allocation failure.
Signed-off-by: Yunseong Kim <yskelg@xxxxxxxxx>
---
tools/perf/util/unwind-libunwind-local.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index cde267ea3e99..a424eae6d308 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -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);
--
2.45.2