Message ID | 20230810120424.2108348-1-ruanjinjie@huawei.com |
---|---|
State | Accepted |
Commit | a895037e1e98cd71f31ef3e4f266fb19d577b621 |
Headers | show |
Series | [-next] drm/msm/adreno: adreno_gpu: Switch to memdup_user_nul() helper | expand |
On 10/08/2023 15:04, Ruan Jinjie wrote: > Use memdup_user_nul() helper instead of open-coding to simplify the code. > > Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> > --- > drivers/gpu/drm/msm/adreno/adreno_gpu.c | 14 +++----------- > 1 file changed, 3 insertions(+), 11 deletions(-) Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index 5c5901d65950..9416c41cd13f 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -400,17 +400,9 @@ int adreno_set_param(struct msm_gpu *gpu, struct msm_file_private *ctx, case MSM_PARAM_CMDLINE: { char *str, **paramp; - str = kmalloc(len + 1, GFP_KERNEL); - if (!str) - return -ENOMEM; - - if (copy_from_user(str, u64_to_user_ptr(value), len)) { - kfree(str); - return -EFAULT; - } - - /* Ensure string is null terminated: */ - str[len] = '\0'; + str = memdup_user_nul(u64_to_user_ptr(value), len); + if (IS_ERR(str)) + return PTR_ERR(str); mutex_lock(&gpu->lock);
Use memdup_user_nul() helper instead of open-coding to simplify the code. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)