drivers/usb/gadget/function/f_fs.c:899:13: sparse: sparse: non size-preserving integer to pointer cast

From: kernel test robot
Date: Wed Jul 08 2020 - 11:58:27 EST


Hi Masahiro,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: dcde237b9b0eb1d19306e6f48c0a4e058907619f
commit: df8df5e4bc37e39010cfdf5d50cf726fe08aae5b usb: get rid of 'choice' for legacy gadget drivers
date: 4 months ago
config: s390-randconfig-s031-20200708 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-37-gc9676a3b-dirty
git checkout df8df5e4bc37e39010cfdf5d50cf726fe08aae5b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=s390

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)

drivers/usb/gadget/function/f_fs.c:2857:32: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [usertype] wMaxPacketSize @@ got restricted __le16 [usertype] wMaxPacketSize @@
drivers/usb/gadget/function/f_fs.c:2857:32: sparse: expected unsigned short [usertype] wMaxPacketSize
drivers/usb/gadget/function/f_fs.c:2857:32: sparse: got restricted __le16 [usertype] wMaxPacketSize
drivers/usb/gadget/function/f_fs.c:2882:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le16 [usertype] wMaxPacketSize @@ got unsigned short [usertype] wMaxPacketSize @@
drivers/usb/gadget/function/f_fs.c:2882:36: sparse: expected restricted __le16 [usertype] wMaxPacketSize
drivers/usb/gadget/function/f_fs.c:2882:36: sparse: got unsigned short [usertype] wMaxPacketSize
>> drivers/usb/gadget/function/f_fs.c:899:13: sparse: sparse: non size-preserving integer to pointer cast
drivers/usb/gadget/function/f_fs.c:937:13: sparse: sparse: non size-preserving integer to pointer cast

vim +899 drivers/usb/gadget/function/f_fs.c

a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 871
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 872 /* Assumes epfile->mutex is held. */
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 873 static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile,
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 874 struct iov_iter *iter)
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 875 {
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 876 /*
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 877 * Null out epfile->read_buffer so ffs_func_eps_disable does not free
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 878 * the buffer while we are using it. See comment in struct ffs_epfile
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 879 * for full read_buffer pointer synchronisation story.
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 880 */
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 881 struct ffs_buffer *buf = xchg(&epfile->read_buffer, NULL);
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 882 ssize_t ret;
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 883 if (!buf || buf == READ_BUFFER_DROP)
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 884 return 0;
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 885
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 886 ret = copy_to_iter(buf->data, buf->length, iter);
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 887 if (buf->length == ret) {
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 888 kfree(buf);
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 889 return ret;
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 890 }
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 891
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 892 if (unlikely(iov_iter_count(iter))) {
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 893 ret = -EFAULT;
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 894 } else {
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 895 buf->length -= ret;
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 896 buf->data += ret;
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 897 }
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 898
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 @899 if (cmpxchg(&epfile->read_buffer, NULL, buf))
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 900 kfree(buf);
a9e6f83c2df1991 Michal Nazarewicz 2016-10-04 901
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 902 return ret;
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 903 }
9353afbbfa7b107 Michal Nazarewicz 2016-05-21 904

:::::: The code at line 899 was first introduced by commit
:::::: a9e6f83c2df199187a5248f824f31b6787ae23ae usb: gadget: f_fs: stop sleeping in ffs_func_eps_disable

:::::: TO: Michal Nazarewicz <mina86@xxxxxxxxxx>
:::::: CC: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip