[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200722011754.869289038@goodmis.org>
Date: Tue, 21 Jul 2020 21:16:45 -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 17/23 v3] tools lib traceevent: Handle strdup() error in parse_option_name()
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@...il.com>
Modified internal function parse_option_name() to return error and handle
that error in function callers in case strdup() fails.
Link: https://lore.kernel.org/r/CAM9d7cizjF+fbK7YzmsBDgrx__4YAOsmEq67D3sWET8FF+YdFA@mail.gmail.com
Link: https://lore.kernel.org/linux-trace-devel/20200714103027.2477584-3-tz.stoyanov@gmail.com
Link: https://lore.kernel.org/linux-trace-devel/20200716092014.2613403-3-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 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index aa6f43290cd3..a39eeb6ef1f2 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -254,7 +254,7 @@ void tep_plugin_remove_options(struct tep_plugin_option *options)
}
}
-static void parse_option_name(char **option, char **plugin)
+static int parse_option_name(char **option, char **plugin)
{
char *p;
@@ -265,8 +265,9 @@ static void parse_option_name(char **option, char **plugin)
*p = '\0';
*option = strdup(p + 1);
if (!*option)
- return;
+ return -1;
}
+ return 0;
}
static struct tep_plugin_option *
@@ -325,7 +326,8 @@ int tep_plugin_add_option(const char *name, const char *val)
if (!option_str)
return -ENOMEM;
- parse_option_name(&option_str, &plugin);
+ if (parse_option_name(&option_str, &plugin) < 0)
+ return -ENOMEM;
/* If the option exists, update the val */
for (op = trace_plugin_options; op; op = op->next) {
--
2.26.2
Powered by blists - more mailing lists