Commit a895037e authored by Ruan Jinjie's avatar Ruan Jinjie Committed by Rob Clark

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: default avatarRuan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: default avatarBjorn Andersson <quic_bjorande@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/552130/Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 42854f8d
...@@ -397,17 +397,9 @@ int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx, ...@@ -397,17 +397,9 @@ int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
case MSM_PARAM_CMDLINE: { case MSM_PARAM_CMDLINE: {
char *str, **paramp; char *str, **paramp;
str = kmalloc(len + 1, GFP_KERNEL); str = memdup_user_nul(u64_to_user_ptr(value), len);
if (!str) if (IS_ERR(str))
return -ENOMEM; return PTR_ERR(str);
if (copy_from_user(str, u64_to_user_ptr(value), len)) {
kfree(str);
return -EFAULT;
}
/* Ensure string is null terminated: */
str[len] = '\0';
mutex_lock(&gpu->lock); mutex_lock(&gpu->lock);
......
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