[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231129094202.11500-1-zhaimingbing@cmss.chinamobile.com>
Date: Wed, 29 Nov 2023 17:42:02 +0800
From: zhaimingbing <zhaimingbing@...s.chinamobile.com>
To: Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Sean Christopherson <seanjc@...gle.com>,
Li Dong <lidong@...o.com>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
zhaimingbing <zhaimingbing@...s.chinamobile.com>
Subject: [PATCH] perf help:Fail check on dynamic allocation
Return error if dynamic allocation failed.
Signed-off-by: zhaimingbing <zhaimingbing@...s.chinamobile.com>
---
tools/perf/builtin-help.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index b2a368ae2..ca05cc795 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -196,6 +196,11 @@ static void add_man_viewer(const char *name)
while (*p)
p = &((*p)->next);
*p = zalloc(sizeof(**p) + len + 1);
+ if(!*p) {
+ pr_err("Failed to zalloc man viewer list\n");
+ return ;
+ }
+
strcpy((*p)->name, name);
}
@@ -211,6 +216,10 @@ static void do_add_man_viewer_info(const char *name,
const char *value)
{
struct man_viewer_info_list *new = zalloc(sizeof(*new) + len + 1);
+ if(!new) {
+ pr_err("Failed to zalloc man viewer info list\n");
+ return ;
+ }
strncpy(new->name, name, len);
new->info = strdup(value);
--
2.33.0
Powered by blists - more mailing lists