aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzvetomir Stoyanov (VMware) <[email protected]>2020-07-21 21:16:51 -0400
committerArnaldo Carvalho de Melo <[email protected]>2020-08-06 09:27:50 -0300
commit7d65864b3b4fcc106d147f8a03bce7f8354f8984 (patch)
tree7093e1776fc3e2f0e339c52cdb615864b68b342e
parentdb885ed481b33bb4b782ca9a76841bc9ec0e2d8f (diff)
tools lib traceevent: Handle possible strdup() error in tep_add_plugin_path() API
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/[email protected] Link: https://lore.kernel.org/linux-trace-devel/[email protected] Suggested-by: Namhyung Kim <[email protected]> Signed-off-by: Tzvetomir Stoyanov (VMware) <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Steven Rostedt (VMware) <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/lib/traceevent/event-plugin.c4
1 files changed, 4 insertions, 0 deletions
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;