Free allocated resources and return -1 in case strdup() fails in tep_add_plugin_path() API. Link: https://lore.kernel.org/linux-trace-devel/CAM9d7cgMgqFDvKhs6xwdBSMsaG=3ZG0RtxwgQDCTLGkML1MY4Q@xxxxxxxxxxxxxx/T/#m60f797c012680cc413a98ffdd9136666efcc4ded Suggested-by: Namhyung Kim <namhyung@xxxxxxxxxx> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- lib/traceevent/event-plugin.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/traceevent/event-plugin.c b/lib/traceevent/event-plugin.c index 841e41c6..4a3f7d3f 100644 --- a/lib/traceevent/event-plugin.c +++ b/lib/traceevent/event-plugin.c @@ -666,6 +666,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