lkml.org 
[lkml]   [2021]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 3/6] tracing: Update synth command errors
On Thu, 21 Jan 2021 11:01:06 -0600
Tom Zanussi <zanussi@kernel.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;
> +}
> +

\
 
 \ /
  Last update: 2021-01-22 22:10    [W:1.031 / U:23.840 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site