From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Yang Yingliang <yangyingliang@huawei.com>,
linux-kernel@vger.kernel.org, freedreno@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org
Cc: quic_abhinavk@quicinc.com
Subject: Re: [PATCH -next] drm/msm/adreno: Switch to memdup_user_nul() helper
Date: Fri, 26 Aug 2022 13:12:18 +0300 [thread overview]
Message-ID: <941ddc17-87d3-aa3c-e6bb-46ecf4a7dfca@linaro.org> (raw)
In-Reply-To: <20220826084524.2217022-1-yangyingliang@huawei.com>
On 26/08/2022 11:45, Yang Yingliang wrote:
> Use memdup_user_nul() helper instead of open-coding to
> simplify the code.
>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> drivers/gpu/drm/msm/adreno/adreno_gpu.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 382fb7f9e497..50b33e14237b 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -339,17 +339,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);
>
> if (param == MSM_PARAM_COMM) {
> paramp = &ctx->comm;
--
With best wishes
Dmitry
prev parent reply other threads:[~2022-08-26 10:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 8:45 [PATCH -next] drm/msm/adreno: Switch to memdup_user_nul() helper Yang Yingliang
2022-08-26 10:12 ` Dmitry Baryshkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=941ddc17-87d3-aa3c-e6bb-46ecf4a7dfca@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_abhinavk@quicinc.com \
--cc=yangyingliang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).