[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231124083910.10169-1-zhaimingbing@cmss.chinamobile.com>
Date: Fri, 24 Nov 2023 16:39:10 +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 NULL if dynamic allocation failed.
Signed-off-by: zhaimingbing <zhaimingbing@...s.chinamobile.com>
---
tools/perf/builtin-help.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index b2a368ae2..e89734dbb 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -196,6 +196,9 @@ static void add_man_viewer(const char *name)
while (*p)
p = &((*p)->next);
*p = zalloc(sizeof(**p) + len + 1);
+ if(!*p)
+ return NULL;
+
strcpy((*p)->name, name);
}
@@ -211,6 +214,8 @@ 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)
+ return NULL;
strncpy(new->name, name, len);
new->info = strdup(value);
--
2.33.0
Powered by blists - more mailing lists