drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c:1920:7-14: WARNING opportunity for memdup_user
From: kernel test robot
Date: Mon Dec 16 2024 - 01:53:52 EST
Hi Dave,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8
commit: 165e8cc3cfec9ef51f3376b0d49b115294f34f3b staging: gpib: Add KBUILD files for GPIB drivers
date: 10 weeks ago
config: x86_64-randconfig-104-20241216 (https://download.01.org/0day-ci/archive/20241216/202412161428.VkrrQFab-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412161428.VkrrQFab-lkp@xxxxxxxxx/
cocci warnings: (new ones prefixed by >>)
>> drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c:1920:7-14: WARNING opportunity for memdup_user
vim +1920 drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
fce79512a96afac Dave Penkler 2024-09-18 1906
fce79512a96afac Dave Penkler 2024-09-18 1907 /*
fce79512a96afac Dave Penkler 2024-09-18 1908 * user space access to write function
fce79512a96afac Dave Penkler 2024-09-18 1909 */
fce79512a96afac Dave Penkler 2024-09-18 1910
fce79512a96afac Dave Penkler 2024-09-18 1911 static ssize_t skel_write(struct file *file, const char *user_buffer,
fce79512a96afac Dave Penkler 2024-09-18 1912 size_t count, loff_t *ppos)
fce79512a96afac Dave Penkler 2024-09-18 1913 {
fce79512a96afac Dave Penkler 2024-09-18 1914 struct usb_skel *dev;
fce79512a96afac Dave Penkler 2024-09-18 1915 char *buf;
fce79512a96afac Dave Penkler 2024-09-18 1916 ssize_t rv;
fce79512a96afac Dave Penkler 2024-09-18 1917
fce79512a96afac Dave Penkler 2024-09-18 1918 dev = file->private_data;
fce79512a96afac Dave Penkler 2024-09-18 1919
fce79512a96afac Dave Penkler 2024-09-18 @1920 buf = kmalloc(count, GFP_KERNEL);
fce79512a96afac Dave Penkler 2024-09-18 1921 if (!buf)
fce79512a96afac Dave Penkler 2024-09-18 1922 return -ENOMEM;
fce79512a96afac Dave Penkler 2024-09-18 1923
fce79512a96afac Dave Penkler 2024-09-18 1924 if (copy_from_user(buf, user_buffer, count)) {
fce79512a96afac Dave Penkler 2024-09-18 1925 kfree(buf);
fce79512a96afac Dave Penkler 2024-09-18 1926 return -EFAULT;
fce79512a96afac Dave Penkler 2024-09-18 1927 }
fce79512a96afac Dave Penkler 2024-09-18 1928
fce79512a96afac Dave Penkler 2024-09-18 1929 rv = skel_do_write(dev, buf, count);
fce79512a96afac Dave Penkler 2024-09-18 1930 kfree(buf);
fce79512a96afac Dave Penkler 2024-09-18 1931 return rv;
fce79512a96afac Dave Penkler 2024-09-18 1932 }
fce79512a96afac Dave Penkler 2024-09-18 1933 #endif
fce79512a96afac Dave Penkler 2024-09-18 1934
:::::: The code at line 1920 was first introduced by commit
:::::: fce79512a96afacbe297ba3c5c2f7ed34944540d staging: gpib: Add LPVO DIY USB GPIB driver
:::::: TO: Dave Penkler <dpenkler@xxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki