Skip to content

Commit a895037

Browse files
Ruan Jinjierobclark
authored andcommitted
drm/msm/adreno: adreno_gpu: Switch to memdup_user_nul() helper
Use memdup_user_nul() helper instead of open-coding to simplify the code. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com> Patchwork: https://patchwork.freedesktop.org/patch/552130/ Signed-off-by: Rob Clark <robdclark@chromium.org>
1 parent 42854f8 commit a895037

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,9 @@ int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
397397
case MSM_PARAM_CMDLINE: {
398398
char *str, **paramp;
399399

400-
str = kmalloc(len + 1, GFP_KERNEL);
401-
if (!str)
402-
return -ENOMEM;
403-
404-
if (copy_from_user(str, u64_to_user_ptr(value), len)) {
405-
kfree(str);
406-
return -EFAULT;
407-
}
408-
409-
/* Ensure string is null terminated: */
410-
str[len] = '\0';
400+
str = memdup_user_nul(u64_to_user_ptr(value), len);
401+
if (IS_ERR(str))
402+
return PTR_ERR(str);
411403

412404
mutex_lock(&gpu->lock);
413405

0 commit comments

Comments
 (0)