[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202210190402.VbDLLIoJ-lkp@intel.com>
Date: Wed, 19 Oct 2022 04:39:08 +0800
From: kernel test robot <lkp@...el.com>
To: Stafford Horne <shorne@...il.com>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: drivers/pci/proc.c:148:17: sparse: sparse: restricted __le16
degrades to integer
Hi Stafford,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: bb1a1146467ad812bb65440696df0782e2bc63c8
commit: ded2ee36313c941f1a12b6f85cde295b575264ae openrisc: Add pci bus support
date: 3 months ago
config: openrisc-randconfig-s051-20221018
compiler: or1k-linux-gcc (GCC) 12.1.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.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ded2ee36313c941f1a12b6f85cde295b575264ae
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout ded2ee36313c941f1a12b6f85cde295b575264ae
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=openrisc SHELL=/bin/bash drivers/pci/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
drivers/pci/proc.c:148:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:148:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:148:17: sparse: sparse: cast to restricted __le16
>> drivers/pci/proc.c:148:17: sparse: sparse: restricted __le16 degrades to integer
>> drivers/pci/proc.c:148:17: sparse: sparse: restricted __le16 degrades to integer
drivers/pci/proc.c:148:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:148:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:157:17: sparse: sparse: cast to restricted __le32
drivers/pci/proc.c:157:17: sparse: sparse: cast to restricted __le32
drivers/pci/proc.c:157:17: sparse: sparse: cast to restricted __le32
>> drivers/pci/proc.c:157:17: sparse: sparse: restricted __le32 degrades to integer
>> drivers/pci/proc.c:157:17: sparse: sparse: restricted __le32 degrades to integer
drivers/pci/proc.c:157:17: sparse: sparse: cast to restricted __le32
drivers/pci/proc.c:157:17: sparse: sparse: cast to restricted __le32
drivers/pci/proc.c:166:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:166:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:166:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:166:17: sparse: sparse: restricted __le16 degrades to integer
drivers/pci/proc.c:166:17: sparse: sparse: restricted __le16 degrades to integer
drivers/pci/proc.c:166:17: sparse: sparse: cast to restricted __le16
drivers/pci/proc.c:166:17: sparse: sparse: cast to restricted __le16
vim +148 drivers/pci/proc.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 110
3c78bc61f5ef3b Ryan Desfosses 2014-04-18 111 static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
3c78bc61f5ef3b Ryan Desfosses 2014-04-18 112 size_t nbytes, loff_t *ppos)
^1da177e4c3f41 Linus Torvalds 2005-04-16 113 {
496ad9aa8ef448 Al Viro 2013-01-23 114 struct inode *ino = file_inode(file);
359745d78351c6 Muchun Song 2022-01-21 115 struct pci_dev *dev = pde_data(ino);
^1da177e4c3f41 Linus Torvalds 2005-04-16 116 int pos = *ppos;
d9dda78bad8795 Al Viro 2013-03-31 117 int size = dev->cfg_size;
eb627e17727ebe Matthew Garrett 2019-08-19 118 int cnt, ret;
eb627e17727ebe Matthew Garrett 2019-08-19 119
eb627e17727ebe Matthew Garrett 2019-08-19 120 ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
eb627e17727ebe Matthew Garrett 2019-08-19 121 if (ret)
eb627e17727ebe Matthew Garrett 2019-08-19 122 return ret;
^1da177e4c3f41 Linus Torvalds 2005-04-16 123
^1da177e4c3f41 Linus Torvalds 2005-04-16 124 if (pos >= size)
^1da177e4c3f41 Linus Torvalds 2005-04-16 125 return 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 126 if (nbytes >= size)
^1da177e4c3f41 Linus Torvalds 2005-04-16 127 nbytes = size;
^1da177e4c3f41 Linus Torvalds 2005-04-16 128 if (pos + nbytes > size)
^1da177e4c3f41 Linus Torvalds 2005-04-16 129 nbytes = size - pos;
^1da177e4c3f41 Linus Torvalds 2005-04-16 130 cnt = nbytes;
^1da177e4c3f41 Linus Torvalds 2005-04-16 131
96d4f267e40f95 Linus Torvalds 2019-01-03 132 if (!access_ok(buf, cnt))
^1da177e4c3f41 Linus Torvalds 2005-04-16 133 return -EINVAL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 134
b3c32c4f9565f9 Huang Ying 2012-10-25 135 pci_config_pm_runtime_get(dev);
b3c32c4f9565f9 Huang Ying 2012-10-25 136
^1da177e4c3f41 Linus Torvalds 2005-04-16 137 if ((pos & 1) && cnt) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 138 unsigned char val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 139 __get_user(val, buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 140 pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds 2005-04-16 141 buf++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 142 pos++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 143 cnt--;
^1da177e4c3f41 Linus Torvalds 2005-04-16 144 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 145
^1da177e4c3f41 Linus Torvalds 2005-04-16 146 if ((pos & 3) && cnt > 2) {
f17a077e61b627 Harvey Harrison 2008-07-22 147 __le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @148 __get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 149 pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds 2005-04-16 150 buf += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 151 pos += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 152 cnt -= 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 153 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 154
^1da177e4c3f41 Linus Torvalds 2005-04-16 155 while (cnt >= 4) {
f17a077e61b627 Harvey Harrison 2008-07-22 156 __le32 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @157 __get_user(val, (__le32 __user *) buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 158 pci_user_write_config_dword(dev, pos, le32_to_cpu(val));
^1da177e4c3f41 Linus Torvalds 2005-04-16 159 buf += 4;
^1da177e4c3f41 Linus Torvalds 2005-04-16 160 pos += 4;
^1da177e4c3f41 Linus Torvalds 2005-04-16 161 cnt -= 4;
^1da177e4c3f41 Linus Torvalds 2005-04-16 162 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 163
^1da177e4c3f41 Linus Torvalds 2005-04-16 164 if (cnt >= 2) {
f17a077e61b627 Harvey Harrison 2008-07-22 165 __le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22 166 __get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 167 pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds 2005-04-16 168 buf += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 169 pos += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 170 cnt -= 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 171 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 172
^1da177e4c3f41 Linus Torvalds 2005-04-16 173 if (cnt) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 174 unsigned char val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 175 __get_user(val, buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 176 pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds 2005-04-16 177 pos++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 178 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 179
b3c32c4f9565f9 Huang Ying 2012-10-25 180 pci_config_pm_runtime_put(dev);
b3c32c4f9565f9 Huang Ying 2012-10-25 181
^1da177e4c3f41 Linus Torvalds 2005-04-16 182 *ppos = pos;
d9dda78bad8795 Al Viro 2013-03-31 183 i_size_write(ino, dev->cfg_size);
^1da177e4c3f41 Linus Torvalds 2005-04-16 184 return nbytes;
^1da177e4c3f41 Linus Torvalds 2005-04-16 185 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 186
:::::: The code at line 148 was first introduced by commit
:::::: f17a077e61b627e58db5926bc474cf308318dad9 PCI: fixup sparse endianness warnings in proc.c
:::::: TO: Harvey Harrison <harvey.harrison@...il.com>
:::::: CC: Jesse Barnes <jbarnes@...tuousgeek.org>
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (160084 bytes)
Powered by blists - more mailing lists