]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
libtraceevent: Handle strdup() error in parse_option_name()
authorTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Wed, 22 Jul 2020 01:16:45 +0000 (21:16 -0400)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 6 Aug 2020 12:26:28 +0000 (09:26 -0300)
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@kernel.org>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lore.kernel.org/lkml/20200722011754.869289038@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/traceevent/event-plugin.c

index aa6f43290cd3d7c1a527928ca709e2b878c093ac..a39eeb6ef1f27b99eb2394e652cdb9b2e313b72c 100644 (file)
@@ -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) {