drivers/watchdog/m54xx_wdt.c:104:37: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Wed Jan 06 2021 - 18:49:19 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62
commit: e5fc436f06eef54ef512ea55a9db8eb9f2e76959 sparse: use static inline for __chk_{user,io}_ptr()
date: 4 months ago
config: m68k-randconfig-s032-20210107 (attached as .config)
compiler: m68k-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.3-208-g46a52ca4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5fc436f06eef54ef512ea55a9db8eb9f2e76959
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout e5fc436f06eef54ef512ea55a9db8eb9f2e76959
# 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=m68k

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/watchdog/m54xx_wdt.c:104:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got char const * @@
drivers/watchdog/m54xx_wdt.c:104:37: sparse: expected void const volatile [noderef] __user *ptr
drivers/watchdog/m54xx_wdt.c:104:37: sparse: got char const *
drivers/watchdog/m54xx_wdt.c:104:37: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__gu_ptr @@ got char const * @@
drivers/watchdog/m54xx_wdt.c:104:37: sparse: expected void const [noderef] __user *__gu_ptr
drivers/watchdog/m54xx_wdt.c:104:37: sparse: got char const *
drivers/watchdog/m54xx_wdt.c:129:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got struct watchdog_info * @@
drivers/watchdog/m54xx_wdt.c:129:37: sparse: expected void [noderef] __user *to
drivers/watchdog/m54xx_wdt.c:129:37: sparse: got struct watchdog_info *
>> drivers/watchdog/m54xx_wdt.c:134:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:134:23: sparse: expected void const volatile [noderef] __user *ptr
drivers/watchdog/m54xx_wdt.c:134:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:134:23: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__pu_ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:134:23: sparse: expected void const [noderef] __user *__pu_ptr
drivers/watchdog/m54xx_wdt.c:134:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:138:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:138:23: sparse: expected void const volatile [noderef] __user *ptr
drivers/watchdog/m54xx_wdt.c:138:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:138:23: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__pu_ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:138:23: sparse: expected void const [noderef] __user *__pu_ptr
drivers/watchdog/m54xx_wdt.c:138:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:147:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:147:23: sparse: expected void const volatile [noderef] __user *ptr
drivers/watchdog/m54xx_wdt.c:147:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:147:23: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__gu_ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:147:23: sparse: expected void const [noderef] __user *__gu_ptr
drivers/watchdog/m54xx_wdt.c:147:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:161:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:161:23: sparse: expected void const volatile [noderef] __user *ptr
drivers/watchdog/m54xx_wdt.c:161:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:161:23: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__pu_ptr @@ got int * @@
drivers/watchdog/m54xx_wdt.c:161:23: sparse: expected void const [noderef] __user *__pu_ptr
drivers/watchdog/m54xx_wdt.c:161:23: sparse: got int *
drivers/watchdog/m54xx_wdt.c:185:27: sparse: sparse: incorrect type in initializer (incompatible argument 2 (different address spaces)) @@ expected int ( *write )( ... ) @@ got int ( * )( ... ) @@
drivers/watchdog/m54xx_wdt.c:185:27: sparse: expected int ( *write )( ... )
drivers/watchdog/m54xx_wdt.c:185:27: sparse: got int ( * )( ... )

vim +104 drivers/watchdog/m54xx_wdt.c

88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 91
9b9c63ff1f3b09a drivers/watchdog/m548x_wdt.c Philippe De Muyter 2011-01-22 92 static ssize_t m54xx_wdt_write(struct file *file, const char *data,
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 93 size_t len, loff_t *ppos)
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 94 {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 95 if (len) {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 96 if (!nowayout) {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 97 size_t i;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 98
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 99 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 100
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 101 for (i = 0; i != len; i++) {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 102 char c;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 103
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 @104 if (get_user(c, data + i))
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 105 return -EFAULT;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 106 if (c == 'V')
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 107 set_bit(WDT_OK_TO_CLOSE, &wdt_status);
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 108 }
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 109 }
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 110 wdt_keepalive();
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 111 }
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 112 return len;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 113 }
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 114
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 115 static const struct watchdog_info ident = {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 116 .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT |
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 117 WDIOF_KEEPALIVEPING,
9b9c63ff1f3b09a drivers/watchdog/m548x_wdt.c Philippe De Muyter 2011-01-22 118 .identity = "Coldfire M54xx Watchdog",
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 119 };
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 120
9b9c63ff1f3b09a drivers/watchdog/m548x_wdt.c Philippe De Muyter 2011-01-22 121 static long m54xx_wdt_ioctl(struct file *file, unsigned int cmd,
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 122 unsigned long arg)
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 123 {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 124 int ret = -ENOTTY;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 125 int time;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 126
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 127 switch (cmd) {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 128 case WDIOC_GETSUPPORT:
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 129 ret = copy_to_user((struct watchdog_info *)arg, &ident,
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 130 sizeof(ident)) ? -EFAULT : 0;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 131 break;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 132
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 133 case WDIOC_GETSTATUS:
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 @134 ret = put_user(0, (int *)arg);
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 135 break;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 136
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 137 case WDIOC_GETBOOTSTATUS:
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 138 ret = put_user(0, (int *)arg);
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 139 break;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 140
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 141 case WDIOC_KEEPALIVE:
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 142 wdt_keepalive();
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 143 ret = 0;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 144 break;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 145
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 146 case WDIOC_SETTIMEOUT:
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 147 ret = get_user(time, (int *)arg);
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 148 if (ret)
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 149 break;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 150
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 151 if (time <= 0 || time > 30) {
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 152 ret = -EINVAL;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 153 break;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 154 }
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 155
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 156 heartbeat = time;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 157 wdt_enable();
bd490f8222510de drivers/watchdog/m54xx_wdt.c Gustavo A. R. Silva 2020-07-07 158 fallthrough;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 159
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 160 case WDIOC_GETTIMEOUT:
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 161 ret = put_user(heartbeat, (int *)arg);
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 162 break;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 163 }
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 164 return ret;
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 165 }
88cce427626070f drivers/watchdog/m548x_wdt.c Philippe De Muyter 2010-11-03 166

:::::: The code at line 104 was first introduced by commit
:::::: 88cce427626070f7d7eb33994e3ff7b4db3292c5 watchdog: Add MCF548x watchdog driver.

:::::: TO: Philippe De Muyter <phdm@xxxxxxxxx>
:::::: CC: Wim Van Sebroeck <wim@xxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip