Skip to content

Commit 7d65864

Browse files
tzstoyanovacmel
authored andcommitted
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]>
1 parent db885ed commit 7d65864

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/lib/traceevent/event-plugin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ int tep_add_plugin_path(struct tep_handle *tep, char *path,
665665
return -1;
666666

667667
dir->path = strdup(path);
668+
if (!dir->path) {
669+
free(dir);
670+
return -1;
671+
}
668672
dir->prio = prio;
669673
dir->next = tep->plugins_dir;
670674
tep->plugins_dir = dir;

0 commit comments

Comments
 (0)