[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210122160600.409936d8@gandalf.local.home>
Date: Fri, 22 Jan 2021 16:06:00 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Tom Zanussi <zanussi@...nel.org>
Cc: axelrasmussen@...gle.com, mhiramat@...nel.org,
dan.carpenter@...cle.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6 3/6] tracing: Update synth command errors
On Thu, 21 Jan 2021 11:01:06 -0600
Tom Zanussi <zanussi@...nel.org> wrote:
> +static int check_command(const char *raw_command)
> +{
> + char **argv = NULL, *cmd, *saved_cmd, *name_and_field;
> + int argc, ret = 0;
> +
> + cmd = saved_cmd = kstrdup(raw_command, GFP_KERNEL);
> + if (!cmd)
> + return -ENOMEM;
> +
> + name_and_field = strsep(&cmd, ";");
> + if (!name_and_field) {
> + ret = -EINVAL;
> + goto free;
> + }
> +
> + if (name_and_field[0] == '!')
> + goto free;
> +
> + argv = argv_split(GFP_KERNEL, name_and_field, &argc);
> + if (!argv) {
> + ret = -ENOMEM;
> + goto free;
> + }
> +
> + if (argc < 3)
> + ret = -EINVAL;
Nit, you can simply put here:
argv_free(argv);
Hmm, is it used at all? If not, just move it after its allocation check.
> +free:
> + kfree(saved_cmd);
> + if (argv)
> + argv_free(argv);
And remove the above, as argv is always NULL when "goto free" is used.
-- Steve
> +
> + return ret;
> +}
> +
Powered by blists - more mailing lists