[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200722011755.720803193@goodmis.org>
Date: Tue, 21 Jul 2020 21:16:51 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: linux-kernel@...r.kernel.org, linux-trace-devel@...r.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Ingo Molnar <mingo@...nel.org>, Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@...il.com>
Subject: [PATCH 23/23 v3] tools lib traceevent: Handle possible strdup() error in
tep_add_plugin_path() API
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@...il.com>
Free allocated resources and return -1 in case strdup() fails in
tep_add_plugin_path() API.
Link: https://lore.kernel.org/r/CAM9d7chfvJwodpVrHGc5E2J80peRojmYV_fD8x3cpn9HFRUw2g@mail.gmail.com
Link: https://lore.kernel.org/linux-trace-devel/20200714103027.2477584-9-tz.stoyanov@gmail.com
Link: https://lore.kernel.org/linux-trace-devel/20200716092014.2613403-9-tz.stoyanov@gmail.com
Suggested-by: Namhyung Kim <namhyung@...nel.org>
Acked-by: Namhyung Kim <namhyung@...nel.org>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@...il.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
tools/lib/traceevent/event-plugin.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index f0877a7e3e8d..e7c2acb8680f 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -665,6 +665,10 @@ int tep_add_plugin_path(struct tep_handle *tep, char *path,
return -1;
dir->path = strdup(path);
+ if (!dir->path) {
+ free(dir);
+ return -1;
+ }
dir->prio = prio;
dir->next = tep->plugins_dir;
tep->plugins_dir = dir;
--
2.26.2
Powered by blists - more mailing lists