[PATCH] perf unwind-libunwind: Add malloc() failure handling

yskelg@gmail.com posted 1 patch 1 year, 7 months ago
tools/perf/util/unwind-libunwind-local.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] perf unwind-libunwind: Add malloc() failure handling
Posted by yskelg@gmail.com 1 year, 7 months ago
From: Yunseong Kim <yskelg@gmail.com>

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@gmail.com>
---
 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
Re: [PATCH] perf unwind-libunwind: Add malloc() failure handling
Posted by Namhyung Kim 1 year, 7 months ago
On Thu, 20 Jun 2024 05:42:12 +0900, yskelg@gmail.com 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
Re: [PATCH] perf unwind-libunwind: Add malloc() failure handling
Posted by Yunseong Kim 1 year, 7 months ago
Hi Namhyung,

On 6/26/24 1:01 오후, Namhyung Kim wrote:
> On Thu, 20 Jun 2024 05:42:12 +0900, yskelg@gmail.com 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)
>>       |                     ~ ^  ~~
>>
>> [...]

> Applied to perf-tools-next, thanks!

Thank you!

>> 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