linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf help:Fail check on dynamic allocation
@ 2023-11-24  8:39 zhaimingbing
  2023-11-24 16:59 ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: zhaimingbing @ 2023-11-24  8:39 UTC (permalink / raw)
  To: Namhyung Kim, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Sean Christopherson,
	Li Dong
  Cc: linux-perf-users, linux-kernel, zhaimingbing

Return NULL if dynamic allocation failed.

Signed-off-by: zhaimingbing <zhaimingbing@cmss.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




^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] perf help:Fail check on dynamic allocation
@ 2023-11-29  9:42 zhaimingbing
  0 siblings, 0 replies; 3+ messages in thread
From: zhaimingbing @ 2023-11-29  9:42 UTC (permalink / raw)
  To: Namhyung Kim, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Sean Christopherson,
	Li Dong
  Cc: linux-perf-users, linux-kernel, zhaimingbing

Return error  if dynamic allocation failed.

Signed-off-by: zhaimingbing <zhaimingbing@cmss.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




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-29  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-24  8:39 [PATCH] perf help:Fail check on dynamic allocation zhaimingbing
2023-11-24 16:59 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2023-11-29  9:42 zhaimingbing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).