[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210308070951.GA83949@8a16bdd473dc>
Date: Mon, 8 Mar 2021 15:09:51 +0800
From: kernel test robot <lkp@...el.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: kbuild-all@...org, linux-kernel@...r.kernel.org,
Peter Chen <peter.chen@....com>,
Felipe Balbi <balbi@...nel.org>, Jens Axboe <axboe@...nel.dk>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Memory Management List <linux-mm@...ck.org>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Lee Jones <lee.jones@...aro.org>,
Vamsi Krishna Samavedam <vskrishn@...eaurora.org>,
Sriharsha Allenki <sallenki@...eaurora.org>
Subject: [PATCH] USB: gadget: f_fs: fix memdup_user.cocci warnings
From: kernel test robot <lkp@...el.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@...el.com>
Signed-off-by: kernel test robot <lkp@...el.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);
Powered by blists - more mailing lists