From: kernel test robot <lkp@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: kbuild-all@01.org, linux-kernel@vger.kernel.org,
Peter Chen <peter.chen@nxp.com>, Felipe Balbi <balbi@kernel.org>,
Jens Axboe <axboe@kernel.dk>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Lee Jones <lee.jones@linaro.org>,
Vamsi Krishna Samavedam <vskrishn@codeaurora.org>,
Sriharsha Allenki <sallenki@codeaurora.org>
Subject: [PATCH] USB: gadget: f_fs: fix memdup_user.cocci warnings
Date: Mon, 8 Mar 2021 15:09:51 +0800 [thread overview]
Message-ID: <20210308070951.GA83949@8a16bdd473dc> (raw)
In-Reply-To: <202103081519.ZUP3wXzn-lkp@intel.com>
From: kernel test robot <lkp@intel.com>
drivers/usb/gadget/function/f_fs.c:3829:8-15: WARNING opportunity for memdup_user
Use memdup_user rather than duplicating its implementation
This is a little bit restricted to reduce false positives
Generated by: scripts/coccinelle/api/memdup_user.cocci
Fixes: 8704fd73bf56 ("USB: gadget: f_fs: remove likely/unlikely")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 144c79ef33536b4ecb4951e07dbc1f2b7fa99d32
commit: 8704fd73bf5658bf4b827643f7f526481082d83f USB: gadget: f_fs: remove likely/unlikely
f_fs.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3826,14 +3826,9 @@ static char *ffs_prepare_buffer(const ch
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);
+ if (IS_ERR(data))
+ return ERR_PTR(PTR_ERR(data));
pr_vdebug("Buffer from user space:\n");
ffs_dump_mem("", data, len);
parent reply other threads:[~2021-03-08 7:10 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <202103081519.ZUP3wXzn-lkp@intel.com>]
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=20210308070951.GA83949@8a16bdd473dc \
--to=lkp@intel.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=kbuild-all@01.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peter.chen@nxp.com \
--cc=sallenki@codeaurora.org \
--cc=vskrishn@codeaurora.org \
/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).