From: Greg KH <greg@kroah.com>
To: Jay Fang <f.fangjian@huawei.com>
Cc: balbi@kernel.org, linux-usb@vger.kernel.org,
tangzihao1@hisilicon.com, huangdaode@huawei.com
Subject: Re: [PATCH] USB: gadget: f_fs: Use memdup_user() as a cleanup
Date: Tue, 23 Mar 2021 12:39:22 +0100 [thread overview]
Message-ID: <YFnTahyNTSQhdclP@kroah.com> (raw)
In-Reply-To: <1616145346-1410-1-git-send-email-f.fangjian@huawei.com>
On Fri, Mar 19, 2021 at 05:15:46PM +0800, Jay Fang wrote:
> From: Zihao Tang <tangzihao1@hisilicon.com>
>
> Fix coccicheck warning which recommends to use memdup_user():
>
> drivers/usb/gadget/function/f_fs.c:3829:8-15: WARNING opportunity for memdup_user
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com>
> Signed-off-by: Jay Fang <f.fangjian@huawei.com>
> ---
> drivers/usb/gadget/function/f_fs.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 801a8b6..2f904f0 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -3826,14 +3826,7 @@ static char *ffs_prepare_buffer(const char __user *buf, size_t len)
> if (!len)
> return NULL;
>
> - data = kmalloc(len, GFP_KERNEL);
> - if (!data)
> - return ERR_PTR(-ENOMEM);
> -
> - if (copy_from_user(data, buf, len)) {
> - kfree(data);
> - return ERR_PTR(-EFAULT);
> - }
> + data = memdup_user(buf, len);
You forgot the error checking :(
prev parent reply other threads:[~2021-03-23 11:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 9:15 [PATCH] USB: gadget: f_fs: Use memdup_user() as a cleanup Jay Fang
2021-03-23 11:39 ` Greg KH [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=YFnTahyNTSQhdclP@kroah.com \
--to=greg@kroah.com \
--cc=balbi@kernel.org \
--cc=f.fangjian@huawei.com \
--cc=huangdaode@huawei.com \
--cc=linux-usb@vger.kernel.org \
--cc=tangzihao1@hisilicon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.