Skip to content

Commit 058612a

Browse files
tzstoyanovacmel
authored andcommitted
libtraceevent: Handle strdup() error in parse_option_name()
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/[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 9dc7dc7 commit 058612a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/lib/traceevent/event-plugin.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void tep_plugin_remove_options(struct tep_plugin_option *options)
254254
}
255255
}
256256

257-
static void parse_option_name(char **option, char **plugin)
257+
static int parse_option_name(char **option, char **plugin)
258258
{
259259
char *p;
260260

@@ -265,8 +265,9 @@ static void parse_option_name(char **option, char **plugin)
265265
*p = '\0';
266266
*option = strdup(p + 1);
267267
if (!*option)
268-
return;
268+
return -1;
269269
}
270+
return 0;
270271
}
271272

272273
static struct tep_plugin_option *
@@ -325,7 +326,8 @@ int tep_plugin_add_option(const char *name, const char *val)
325326
if (!option_str)
326327
return -ENOMEM;
327328

328-
parse_option_name(&option_str, &plugin);
329+
if (parse_option_name(&option_str, &plugin) < 0)
330+
return -ENOMEM;
329331

330332
/* If the option exists, update the val */
331333
for (op = trace_plugin_options; op; op = op->next) {

0 commit comments

Comments
 (0)