* drivers/usb/gadget/function/f_fs.c:3829:8-15: WARNING opportunity for memdup_user
@ 2021-03-08 7:09 kernel test robot
2021-03-08 7:09 ` [PATCH] USB: gadget: f_fs: fix memdup_user.cocci warnings kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2021-03-08 7:09 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: kbuild-all, linux-kernel, Peter Chen
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
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
date: 3 months ago
config: x86_64-randconfig-c002-20210307 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"coccinelle warnings: (new ones prefixed by >>)"
>> drivers/usb/gadget/function/f_fs.c:3829:8-15: WARNING opportunity for memdup_user
Please review and possibly fold the followup patch.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37114 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH] USB: gadget: f_fs: fix memdup_user.cocci warnings 2021-03-08 7:09 drivers/usb/gadget/function/f_fs.c:3829:8-15: WARNING opportunity for memdup_user kernel test robot @ 2021-03-08 7:09 ` kernel test robot 0 siblings, 0 replies; 2+ messages in thread From: kernel test robot @ 2021-03-08 7:09 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: kbuild-all, linux-kernel, Peter Chen, Felipe Balbi, Jens Axboe, Andrew Morton, Linux Memory Management List, Gustavo A. R. Silva, Lee Jones, Vamsi Krishna Samavedam, Sriharsha Allenki 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); ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-08 7:11 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-03-08 7:09 drivers/usb/gadget/function/f_fs.c:3829:8-15: WARNING opportunity for memdup_user kernel test robot 2021-03-08 7:09 ` [PATCH] USB: gadget: f_fs: fix memdup_user.cocci warnings kernel test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox