tracing/osnoise: Replace kmalloc + copy_from_user with memdup_user_nul

Replace kmalloc() followed by copy_from_user() with memdup_user_nul() to
simplify and improve osnoise_cpus_write(). Remove the manual
NUL-termination.

No functional changes intended.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20251001130907.364673-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by Thorsten Blum and committed by Steven Rostedt (Google) f0c029d2 e5f0a698

+4 -7
+4 -7
kernel/trace/trace_osnoise.c
··· 24 #include <linux/sched/clock.h> 25 #include <uapi/linux/sched/types.h> 26 #include <linux/sched.h> 27 #include "trace.h" 28 29 #ifdef CONFIG_X86_LOCAL_APIC ··· 2326 if (count < 1) 2327 return 0; 2328 2329 - buf = kmalloc(count + 1, GFP_KERNEL); 2330 - if (!buf) 2331 - return -ENOMEM; 2332 - 2333 - if (copy_from_user(buf, ubuf, count)) 2334 - return -EFAULT; 2335 - buf[count] = '\0'; 2336 2337 if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL)) 2338 return -ENOMEM;
··· 24 #include <linux/sched/clock.h> 25 #include <uapi/linux/sched/types.h> 26 #include <linux/sched.h> 27 + #include <linux/string.h> 28 #include "trace.h" 29 30 #ifdef CONFIG_X86_LOCAL_APIC ··· 2325 if (count < 1) 2326 return 0; 2327 2328 + buf = memdup_user_nul(ubuf, count); 2329 + if (IS_ERR(buf)) 2330 + return PTR_ERR(buf); 2331 2332 if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL)) 2333 return -ENOMEM;