Re: [PATCH v6 2/6] tracing: Rework synthetic event command parsing

From: Steven Rostedt
Date: Fri Jan 22 2021 - 16:04:34 EST


On Thu, 21 Jan 2021 11:01:05 -0600
Tom Zanussi <zanussi@xxxxxxxxxx> wrote:

> @@ -1208,13 +1173,14 @@ static int __create_synth_event(int argc, const char *name, const char **argv)
> * where 'field' = type field_name
> */
>
> - if (name[0] == '\0' || argc < 1) {
> + mutex_lock(&event_mutex);

I'm curious, why is the event_mutex taken here? I'm guessing it is first
needed for the find_synth_event() call, in which case, it can be moved
after the is_good_name() check. I don't see why the goto out is required
here or for the is_good_name() check.

-- Steve

> +
> + if (name[0] == '\0') {
> synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto out;
> }
>
> - mutex_lock(&event_mutex);
> -
> if (!is_good_name(name)) {
> synth_err(SYNTH_ERR_BAD_NAME, errpos(name));
> ret = -EINVAL;