From: kernel test robot <lkp@intel.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@lst.de>
Subject: drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
Date: Thu, 31 Mar 2022 15:42:24 +0800 [thread overview]
Message-ID: <202203311536.W1IL3Too-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 787af64d05cd528aac9ad16752d11bb1c6061bb9
commit: a97b693c3712f040c5802f32b2d685352e08cefa uaccess: fix nios2 and microblaze get_user_8()
date: 5 weeks ago
config: microblaze-randconfig-s032-20220331 (https://download.01.org/0day-ci/archive/20220331/202203311536.W1IL3Too-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.2.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-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a97b693c3712f040c5802f32b2d685352e08cefa
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout a97b693c3712f040c5802f32b2d685352e08cefa
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/pci/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
drivers/pci/proc.c:150:17: sparse: sparse: cast to restricted __le16
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
drivers/pci/proc.c:159:17: sparse: sparse: cast to restricted __le32
drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
drivers/pci/proc.c:168:17: sparse: sparse: cast to restricted __le16
vim +150 drivers/pci/proc.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 112
3c78bc61f5ef3b Ryan Desfosses 2014-04-18 113 static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
3c78bc61f5ef3b Ryan Desfosses 2014-04-18 114 size_t nbytes, loff_t *ppos)
^1da177e4c3f41 Linus Torvalds 2005-04-16 115 {
496ad9aa8ef448 Al Viro 2013-01-23 116 struct inode *ino = file_inode(file);
359745d78351c6 Muchun Song 2022-01-21 117 struct pci_dev *dev = pde_data(ino);
^1da177e4c3f41 Linus Torvalds 2005-04-16 118 int pos = *ppos;
d9dda78bad8795 Al Viro 2013-03-31 119 int size = dev->cfg_size;
eb627e17727ebe Matthew Garrett 2019-08-19 120 int cnt, ret;
eb627e17727ebe Matthew Garrett 2019-08-19 121
eb627e17727ebe Matthew Garrett 2019-08-19 122 ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
eb627e17727ebe Matthew Garrett 2019-08-19 123 if (ret)
eb627e17727ebe Matthew Garrett 2019-08-19 124 return ret;
^1da177e4c3f41 Linus Torvalds 2005-04-16 125
^1da177e4c3f41 Linus Torvalds 2005-04-16 126 if (pos >= size)
^1da177e4c3f41 Linus Torvalds 2005-04-16 127 return 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 128 if (nbytes >= size)
^1da177e4c3f41 Linus Torvalds 2005-04-16 129 nbytes = size;
^1da177e4c3f41 Linus Torvalds 2005-04-16 130 if (pos + nbytes > size)
^1da177e4c3f41 Linus Torvalds 2005-04-16 131 nbytes = size - pos;
^1da177e4c3f41 Linus Torvalds 2005-04-16 132 cnt = nbytes;
^1da177e4c3f41 Linus Torvalds 2005-04-16 133
96d4f267e40f95 Linus Torvalds 2019-01-03 134 if (!access_ok(buf, cnt))
^1da177e4c3f41 Linus Torvalds 2005-04-16 135 return -EINVAL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 136
b3c32c4f9565f9 Huang Ying 2012-10-25 137 pci_config_pm_runtime_get(dev);
b3c32c4f9565f9 Huang Ying 2012-10-25 138
^1da177e4c3f41 Linus Torvalds 2005-04-16 139 if ((pos & 1) && cnt) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 140 unsigned char val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 141 __get_user(val, buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 142 pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds 2005-04-16 143 buf++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 144 pos++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 145 cnt--;
^1da177e4c3f41 Linus Torvalds 2005-04-16 146 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 147
^1da177e4c3f41 Linus Torvalds 2005-04-16 148 if ((pos & 3) && cnt > 2) {
f17a077e61b627 Harvey Harrison 2008-07-22 149 __le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @150 __get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 151 pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds 2005-04-16 152 buf += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 153 pos += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 154 cnt -= 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 155 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 156
^1da177e4c3f41 Linus Torvalds 2005-04-16 157 while (cnt >= 4) {
f17a077e61b627 Harvey Harrison 2008-07-22 158 __le32 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @159 __get_user(val, (__le32 __user *) buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 160 pci_user_write_config_dword(dev, pos, le32_to_cpu(val));
^1da177e4c3f41 Linus Torvalds 2005-04-16 161 buf += 4;
^1da177e4c3f41 Linus Torvalds 2005-04-16 162 pos += 4;
^1da177e4c3f41 Linus Torvalds 2005-04-16 163 cnt -= 4;
^1da177e4c3f41 Linus Torvalds 2005-04-16 164 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 165
^1da177e4c3f41 Linus Torvalds 2005-04-16 166 if (cnt >= 2) {
f17a077e61b627 Harvey Harrison 2008-07-22 167 __le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22 168 __get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 169 pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds 2005-04-16 170 buf += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 171 pos += 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 172 cnt -= 2;
^1da177e4c3f41 Linus Torvalds 2005-04-16 173 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 174
^1da177e4c3f41 Linus Torvalds 2005-04-16 175 if (cnt) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 176 unsigned char val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 177 __get_user(val, buf);
e04b0ea2e0f9c1 Brian King 2005-09-27 178 pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds 2005-04-16 179 buf++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 180 pos++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 181 cnt--;
^1da177e4c3f41 Linus Torvalds 2005-04-16 182 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 183
b3c32c4f9565f9 Huang Ying 2012-10-25 184 pci_config_pm_runtime_put(dev);
b3c32c4f9565f9 Huang Ying 2012-10-25 185
^1da177e4c3f41 Linus Torvalds 2005-04-16 186 *ppos = pos;
d9dda78bad8795 Al Viro 2013-03-31 187 i_size_write(ino, dev->cfg_size);
^1da177e4c3f41 Linus Torvalds 2005-04-16 188 return nbytes;
^1da177e4c3f41 Linus Torvalds 2005-04-16 189 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 190
:::::: The code at line 150 was first introduced by commit
:::::: f17a077e61b627e58db5926bc474cf308318dad9 PCI: fixup sparse endianness warnings in proc.c
:::::: TO: Harvey Harrison <harvey.harrison@gmail.com>
:::::: CC: Jesse Barnes <jbarnes@virtuousgeek.org>
--
0-DAY CI Kernel Test Service
https://01.org/lkp
next reply other threads:[~2022-03-31 7:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 7:42 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-06-04 7:54 drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer kernel test robot
2022-03-28 3:04 kernel test robot
2022-03-29 6:56 ` Christoph Hellwig
2022-03-29 6:56 ` Christoph Hellwig
2022-03-31 8:43 ` Arnd Bergmann
2022-03-31 8:43 ` Arnd Bergmann
2022-03-31 8:43 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202203311536.W1IL3Too-lkp@intel.com \
--to=lkp@intel.com \
--cc=arnd@arndb.de \
--cc=hch@lst.de \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.