From: "Luca Weiss" <luca.weiss@fairphone.com>
To: "Yang Li" <yang.lee@linux.alibaba.com>, <srinivas.kandagatla@linaro.org>
Cc: <amahesh@qti.qualcomm.com>, <arnd@arndb.de>,
<linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Abaci Robot" <abaci@linux.alibaba.com>
Subject: Re: [PATCH -next] fastrpc: Use memdup_user instead of kmalloc/copy_from_user
Date: Mon, 15 May 2023 11:37:55 +0200 [thread overview]
Message-ID: <CSMR1BXJMLYU.1YUU6374U6T7H@otso> (raw)
In-Reply-To: <20230515092604.79990-1-yang.lee@linux.alibaba.com>
Hi Yang Li,
On Mon May 15, 2023 at 11:26 AM CEST, Yang Li wrote:
> Use memdup_user rather than duplicating its implementation, which
> makes code simple and easy to understand, and silence the following
> warning:
>
> ./drivers/misc/fastrpc.c:1259:8-15: WARNING opportunity for memdup_user
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4949
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
> drivers/misc/fastrpc.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index f60bbf99485c..a897dab13c61 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -1256,16 +1256,9 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
> goto err;
> }
>
> - name = kzalloc(init.namelen, GFP_KERNEL);
> - if (!name) {
> - err = -ENOMEM;
> - goto err;
> - }
> -
> - if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) {
> - err = -EFAULT;
> - goto err_name;
> - }
> + name = memdup_user((void __user *)(uintptr_t)init.name, init.namelen);
> + if (IS_ERR(name))
> + return PTR_ERR(name);
Don't we still need a "goto err;" here to free args?
Something like this:
if (IS_ERR(name)) {
err = PTR_ERR(name);
goto err;
}
Regards
Luca
>
> if (!fl->cctx->remote_heap) {
> err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,
prev parent reply other threads:[~2023-05-15 9:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 9:26 Yang Li
2023-05-15 9:37 ` Luca Weiss [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=CSMR1BXJMLYU.1YUU6374U6T7H@otso \
--to=luca.weiss@fairphone.com \
--cc=abaci@linux.alibaba.com \
--cc=amahesh@qti.qualcomm.com \
--cc=arnd@arndb.de \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=yang.lee@linux.alibaba.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
all inboxes | Powered by JetHome®