[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250930170302.542931839@kernel.org>
Date: Tue, 30 Sep 2025 13:01:43 -0400
From: Steven Rostedt <rostedt@...nel.org>
To: linux-kernel@...r.kernel.org
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Thorsten Blum <thorsten.blum@...ux.dev>
Subject: [for-next][PATCH 08/11] tracing/osnoise: Replace kmalloc() + copy_from_user() with
memdup_user()
From: Thorsten Blum <thorsten.blum@...ux.dev>
Replace kmalloc() followed by copy_from_user() with memdup_user() to
improve and simplify osnoise_cpus_write().
No functional changes intended.
Cc: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Link: https://lore.kernel.org/20250905192116.554018-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
Signed-off-by: Steven Rostedt (Google) <rostedt@...dmis.org>
---
kernel/trace/trace_osnoise.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 4cb464894faf..f8aa9556c695 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2322,12 +2322,9 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
int running, err;
char *buf __free(kfree) = NULL;
- buf = kmalloc(count, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- if (copy_from_user(buf, ubuf, count))
- return -EFAULT;
+ buf = memdup_user(ubuf, count);
+ if (IS_ERR(buf))
+ return PTR_ERR(buf);
if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL))
return -ENOMEM;
--
2.50.1
Powered by blists - more mailing lists