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>
This commit is contained in:
Yang Yingliang 2023-07-25 20:02:47 +08:00 committed by Mark Brown
parent f957172bf7
commit 93fd2be6eb
No known key found for this signature in database
GPG key ID: 24D68B725D5487D0

View file

@ -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)