diff options
author | Yang Yingliang <yangyingliang@huawei.com> | 2023-07-25 15:02:47 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-08-07 21:56:07 +0300 |
commit | 93fd2be6eb80fe37570fbd87652ec07a4f7c5b5a (patch) | |
tree | e69c023e286cd308832d1c07f51a33baef2a4c8e /sound/soc/sof/ipc3-dtrace.c | |
parent | f957172bf7c562df10dc57586118b1cbe15e6b00 (diff) | |
download | linux-93fd2be6eb80fe37570fbd87652ec07a4f7c5b5a.tar.xz |
ASoC: SOF: ipc3-dtrace: Switch to memdup_user_nul() helper
Use memdup_user_nul() helper instead of open-coding to
simplify the code.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20230725120247.509422-1-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/ipc3-dtrace.c')
-rw-r--r-- | sound/soc/sof/ipc3-dtrace.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/sound/soc/sof/ipc3-dtrace.c b/sound/soc/sof/ipc3-dtrace.c index 35da85a45a9a..bd07f0472efd 100644 --- a/sound/soc/sof/ipc3-dtrace.c +++ b/sound/soc/sof/ipc3-dtrace.c @@ -196,15 +196,9 @@ static ssize_t dfsentry_trace_filter_write(struct file *file, const char __user return -EINVAL; } - string = kmalloc(count + 1, GFP_KERNEL); - if (!string) - return -ENOMEM; - - if (copy_from_user(string, from, count)) { - ret = -EFAULT; - goto error; - } - string[count] = '\0'; + string = memdup_user_nul(from, count); + if (IS_ERR(string)) + return PTR_ERR(string); ret = trace_filter_parse(sdev, string, &num_elems, &elems); if (ret < 0) |