if (ret)
                return ret;
 
-       mutex_lock(&event_mutex);
+       guard(mutex)(&event_mutex);
 
-       if (unlikely(!event_file_file(file))) {
-               mutex_unlock(&event_mutex);
+       if (unlikely(!event_file_file(file)))
                return -ENODEV;
-       }
 
        if ((file->f_mode & FMODE_WRITE) &&
            (file->f_flags & O_TRUNC)) {
                }
        }
 
-       mutex_unlock(&event_mutex);
-
        return ret;
 }
 
 {
        char *command, *next;
        struct event_command *p;
-       int ret = -EINVAL;
 
        next = buff = skip_spaces(buff);
        command = strsep(&next, ": \t");
        }
        command = (command[0] != '!') ? command : command + 1;
 
-       mutex_lock(&trigger_cmd_mutex);
+       guard(mutex)(&trigger_cmd_mutex);
+
        list_for_each_entry(p, &trigger_commands, list) {
-               if (strcmp(p->name, command) == 0) {
-                       ret = p->parse(p, file, buff, command, next);
-                       goto out_unlock;
-               }
+               if (strcmp(p->name, command) == 0)
+                       return p->parse(p, file, buff, command, next);
        }
- out_unlock:
-       mutex_unlock(&trigger_cmd_mutex);
 
-       return ret;
+       return -EINVAL;
 }
 
 static ssize_t event_trigger_regex_write(struct file *file,
 {
        struct trace_event_file *event_file;
        ssize_t ret;
-       char *buf;
+       char *buf __free(kfree) = NULL;
 
        if (!cnt)
                return 0;
 
        strim(buf);
 
-       mutex_lock(&event_mutex);
+       guard(mutex)(&event_mutex);
+
        event_file = event_file_file(file);
-       if (unlikely(!event_file)) {
-               mutex_unlock(&event_mutex);
-               kfree(buf);
+       if (unlikely(!event_file))
                return -ENODEV;
-       }
-       ret = trigger_process_regex(event_file, buf);
-       mutex_unlock(&event_mutex);
 
-       kfree(buf);
+       ret = trigger_process_regex(event_file, buf);
        if (ret < 0)
-               goto out;
+               return ret;
 
        *ppos += cnt;
-       ret = cnt;
- out:
-       return ret;
+       return cnt;
 }
 
 static int event_trigger_regex_release(struct inode *inode, struct file *file)
 __init int register_event_command(struct event_command *cmd)
 {
        struct event_command *p;
-       int ret = 0;
 
-       mutex_lock(&trigger_cmd_mutex);
+       guard(mutex)(&trigger_cmd_mutex);
+
        list_for_each_entry(p, &trigger_commands, list) {
-               if (strcmp(cmd->name, p->name) == 0) {
-                       ret = -EBUSY;
-                       goto out_unlock;
-               }
+               if (strcmp(cmd->name, p->name) == 0)
+                       return -EBUSY;
        }
        list_add(&cmd->list, &trigger_commands);
- out_unlock:
-       mutex_unlock(&trigger_cmd_mutex);
 
-       return ret;
+       return 0;
 }
 
 /*
 __init int unregister_event_command(struct event_command *cmd)
 {
        struct event_command *p, *n;
-       int ret = -ENODEV;
 
-       mutex_lock(&trigger_cmd_mutex);
+       guard(mutex)(&trigger_cmd_mutex);
+
        list_for_each_entry_safe(p, n, &trigger_commands, list) {
                if (strcmp(cmd->name, p->name) == 0) {
-                       ret = 0;
                        list_del_init(&p->list);
-                       goto out_unlock;
+                       return 0;
                }
        }
- out_unlock:
-       mutex_unlock(&trigger_cmd_mutex);
 
-       return ret;
+       return -ENODEV;
 }
 
 /**