Commit 9430cd62 authored by Chuang Wang's avatar Chuang Wang Committed by Steven Rostedt (Google)

tracing/perf: Use strndup_user instead of kzalloc/strncpy_from_user

This patch uses strndup_user instead of kzalloc + strncpy_from_user,
which makes the code more concise.

Link: https://lkml.kernel.org/r/20221121080831.707409-1-nashuiliang@gmail.comSigned-off-by: default avatarChuang Wang <nashuiliang@gmail.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 67543cd6
...@@ -251,16 +251,12 @@ int perf_kprobe_init(struct perf_event *p_event, bool is_retprobe) ...@@ -251,16 +251,12 @@ int perf_kprobe_init(struct perf_event *p_event, bool is_retprobe)
struct trace_event_call *tp_event; struct trace_event_call *tp_event;
if (p_event->attr.kprobe_func) { if (p_event->attr.kprobe_func) {
func = kzalloc(KSYM_NAME_LEN, GFP_KERNEL); func = strndup_user(u64_to_user_ptr(p_event->attr.kprobe_func),
if (!func) KSYM_NAME_LEN);
return -ENOMEM; if (IS_ERR(func)) {
ret = strncpy_from_user( ret = PTR_ERR(func);
func, u64_to_user_ptr(p_event->attr.kprobe_func), return (ret == -EINVAL) ? -E2BIG : ret;
KSYM_NAME_LEN); }
if (ret == KSYM_NAME_LEN)
ret = -E2BIG;
if (ret < 0)
goto out;
if (func[0] == '\0') { if (func[0] == '\0') {
kfree(func); kfree(func);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment