diff mbox series

[03/14] tracing: Have event_enable_write() just return error on error

Message ID 20241219201345.025284170@goodmis.org (mailing list archive)
State New
Headers show
Series tracing: Convert over to guard() and __free() infrastructure | expand

Commit Message

Steven Rostedt Dec. 19, 2024, 8:12 p.m. UTC
From: Steven Rostedt <rostedt@goodmis.org>

The event_enable_write() function is inconsistent in how it returns
errors. Sometimes it updates the ppos parameter and sometimes it doesn't.
Simplify the code to just return an error or the count if there isn't an
error.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 1545cc8b49d0..f4eff49faef6 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1549,18 +1549,18 @@  event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	switch (val) {
 	case 0:
 	case 1:
-		ret = -ENODEV;
 		mutex_lock(&event_mutex);
 		file = event_file_file(filp);
 		if (likely(file)) {
 			ret = tracing_update_buffers(file->tr);
-			if (ret < 0) {
-				mutex_unlock(&event_mutex);
-				return ret;
-			}
-			ret = ftrace_event_enable_disable(file, val);
+			if (ret >= 0)
+				ret = ftrace_event_enable_disable(file, val);
+		} else {
+			ret = -ENODEV;
 		}
 		mutex_unlock(&event_mutex);
+		if (ret < 0)
+			return ret;
 		break;
 
 	default:
@@ -1569,7 +1569,7 @@  event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	*ppos += cnt;
 
-	return ret ? ret : cnt;
+	return cnt;
 }
 
 static ssize_t