Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yang Yingliang and committed by
Mark Brown
93fd2be6 f957172b

+3 -9
+3 -9
sound/soc/sof/ipc3-dtrace.c
··· 196 196 return -EINVAL; 197 197 } 198 198 199 - string = kmalloc(count + 1, GFP_KERNEL); 200 - if (!string) 201 - return -ENOMEM; 202 - 203 - if (copy_from_user(string, from, count)) { 204 - ret = -EFAULT; 205 - goto error; 206 - } 207 - string[count] = '\0'; 199 + string = memdup_user_nul(from, count); 200 + if (IS_ERR(string)) 201 + return PTR_ERR(string); 208 202 209 203 ret = trace_filter_parse(sdev, string, &num_elems, &elems); 210 204 if (ret < 0)