drivers/watchdog/ath79_wdt.c:165:37: sparse: sparse: incorrect type in initializer (different address spaces)

From: kernel test robot
Date: Tue Dec 12 2023 - 13:54:55 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 26aff849438cebcd05f1a647390c4aa700d5c0f1
commit: d15155824c5014803d91b829736d249c500bdda6 linux/compiler.h: Split into compiler.h and compiler_types.h
date: 6 years ago
config: arm-randconfig-r131-20231117 (https://download.01.org/0day-ci/archive/20231213/202312130257.RgeLtCBh-lkp@xxxxxxxxx/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231213/202312130257.RgeLtCBh-lkp@xxxxxxxxx/reproduce)

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/202312130257.RgeLtCBh-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> drivers/watchdog/ath79_wdt.c:165:37: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected char const [noderef] __user *register __p @@ got char const * @@
drivers/watchdog/ath79_wdt.c:165:37: sparse: expected char const [noderef] __user *register __p
drivers/watchdog/ath79_wdt.c:165:37: sparse: got char const *
drivers/watchdog/ath79_wdt.c:239:27: sparse: sparse: incorrect type in initializer (incompatible argument 2 (different address spaces)) @@ expected int ( *write )( ... ) @@ got int ( * )( ... ) @@
drivers/watchdog/ath79_wdt.c:239:27: sparse: expected int ( *write )( ... )
drivers/watchdog/ath79_wdt.c:239:27: sparse: got int ( * )( ... )
In file included from include/linux/workqueue.h:8,
from include/linux/mm_types.h:15,
from include/linux/fs.h:21,
from drivers/watchdog/ath79_wdt.c:25:
include/linux/timer.h: In function 'timer_setup':
include/linux/timer.h:178:30: warning: cast between incompatible function types from 'void (*)(struct timer_list *)' to 'void (*)(long unsigned int)' [-Wcast-function-type]
178 | __setup_timer(timer, (TIMER_FUNC_TYPE)callback,
| ^
include/linux/timer.h:143:39: note: in definition of macro '__setup_timer'
143 | (_timer)->function = (_fn); 17- | ^~~
--
kernel/futex.c: note: in included file:
>> arch/arm/include/asm/futex.h:57:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got unsigned int [noderef] [usertype] __user *uaddr @@
arch/arm/include/asm/futex.h:57:9: sparse: expected void const *
arch/arm/include/asm/futex.h:57:9: sparse: got unsigned int [noderef] [usertype] __user *uaddr
kernel/futex.c:1480:9: sparse: sparse: context imbalance in 'wake_futex_pi' - unexpected unlock
arch/arm/include/asm/futex.h:142:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got unsigned int [noderef] [usertype] __user *uaddr @@
arch/arm/include/asm/futex.h:142:17: sparse: expected void const *
arch/arm/include/asm/futex.h:142:17: sparse: got unsigned int [noderef] [usertype] __user *uaddr
arch/arm/include/asm/futex.h:145:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got unsigned int [noderef] [usertype] __user *uaddr @@
arch/arm/include/asm/futex.h:145:17: sparse: expected void const *
arch/arm/include/asm/futex.h:145:17: sparse: got unsigned int [noderef] [usertype] __user *uaddr
arch/arm/include/asm/futex.h:148:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got unsigned int [noderef] [usertype] __user *uaddr @@
arch/arm/include/asm/futex.h:148:17: sparse: expected void const *
arch/arm/include/asm/futex.h:148:17: sparse: got unsigned int [noderef] [usertype] __user *uaddr
arch/arm/include/asm/futex.h:151:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got unsigned int [noderef] [usertype] __user *uaddr @@
arch/arm/include/asm/futex.h:151:17: sparse: expected void const *
arch/arm/include/asm/futex.h:151:17: sparse: got unsigned int [noderef] [usertype] __user *uaddr
arch/arm/include/asm/futex.h:154:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got unsigned int [noderef] [usertype] __user *uaddr @@
arch/arm/include/asm/futex.h:154:17: sparse: expected void const *
arch/arm/include/asm/futex.h:154:17: sparse: got unsigned int [noderef] [usertype] __user *uaddr
kernel/futex.c:1633:33: sparse: sparse: context imbalance in 'futex_wake_op' - different lock contexts for basic block
kernel/futex.c:1924:41: sparse: sparse: context imbalance in 'futex_requeue' - different lock contexts for basic block
kernel/futex.c:2442:13: sparse: sparse: context imbalance in 'futex_wait_queue_me' - unexpected unlock
kernel/futex.c:2545:9: sparse: sparse: context imbalance in 'futex_wait_setup' - different lock contexts for basic block
kernel/futex.c:2834:12: sparse: sparse: context imbalance in 'futex_unlock_pi' - different lock contexts for basic block
kernel/futex.c:3102:29: sparse: sparse: context imbalance in 'futex_wait_requeue_pi' - unexpected unlock
In file included from include/linux/workqueue.h:8,
from include/linux/srcu.h:34,
from include/linux/notifier.h:15,
from include/linux/memory_hotplug.h:6,
from include/linux/mmzone.h:779,
from include/linux/gfp.h:5,
from include/linux/slab.h:14,
from kernel/futex.c:47:
include/linux/timer.h: In function 'timer_setup':
include/linux/timer.h:178:30: warning: cast between incompatible function types from 'void (*)(struct timer_list *)' to 'void (*)(long unsigned int)' [-Wcast-function-type]
178 | __setup_timer(timer, (TIMER_FUNC_TYPE)callback,
| ^
include/linux/timer.h:143:39: note: in definition of macro '__setup_timer'
143 | (_timer)->function = (_fn); 41- | ^~~
In file included from kernel/futex.c:56:
kernel/futex.c: At top level:
include/linux/syscalls.h:211:25: warning: 'sys_set_robust_list' alias between functions of incompatible types 'long int(struct robust_list_head *, size_t)' {aka 'long int(struct robust_list_head *, unsigned int)'} and 'long int(long int, long int)' [-Wattribute-alias=]
211 | asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 46- | ^~~
include/linux/syscalls.h:207:9: note: in expansion of macro '__SYSCALL_DEFINEx'
207 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:197:36: note: in expansion of macro 'SYSCALL_DEFINEx'
197 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/futex.c:3237:1: note: in expansion of macro 'SYSCALL_DEFINE2'
3237 | SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:215:25: note: aliased declaration here
215 | asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) 58- | ^~~
include/linux/syscalls.h:207:9: note: in expansion of macro '__SYSCALL_DEFINEx'
207 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:197:36: note: in expansion of macro 'SYSCALL_DEFINEx'
197 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/futex.c:3237:1: note: in expansion of macro 'SYSCALL_DEFINE2'
3237 | SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:211:25: warning: 'sys_futex' alias between functions of incompatible types 'long int(u32 *, int, u32, struct timespec *, u32 *, u32)' {aka 'long int(unsigned int *, int, unsigned int, struct timespec *, unsigned int *, unsigned int)'} and 'long int(long int, long int, long int, long int, long int, long int)' [-Wattribute-alias=]
211 | asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 70- | ^~~
include/linux/syscalls.h:207:9: note: in expansion of macro '__SYSCALL_DEFINEx'
207 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx'
201 | #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/futex.c:3494:1: note: in expansion of macro 'SYSCALL_DEFINE6'
3494 | SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:215:25: note: aliased declaration here
215 | asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) 82- | ^~~
include/linux/syscalls.h:207:9: note: in expansion of macro '__SYSCALL_DEFINEx'
207 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx'
201 | #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/futex.c:3494:1: note: in expansion of macro 'SYSCALL_DEFINE6'
3494 | SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:211:25: warning: 'sys_get_robust_list' alias between functions of incompatible types 'long int(int, struct robust_list_head **, size_t *)' {aka 'long int(int, struct robust_list_head **, unsigned int *)'} and 'long int(long int, long int, long int)' [-Wattribute-alias=]
211 | asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 94- | ^~~
include/linux/syscalls.h:207:9: note: in expansion of macro '__SYSCALL_DEFINEx'
207 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:198:36: note: in expansion of macro 'SYSCALL_DEFINEx'
198 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/futex.c:3259:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3259 | SYSCALL_DEFINE3(get_robust_list, int, pid,

vim +165 drivers/watchdog/ath79_wdt.c

f8394f61c66f48 Gabor Juhos 2011-01-04 152
f8394f61c66f48 Gabor Juhos 2011-01-04 153 static ssize_t ath79_wdt_write(struct file *file, const char *data,
f8394f61c66f48 Gabor Juhos 2011-01-04 154 size_t len, loff_t *ppos)
f8394f61c66f48 Gabor Juhos 2011-01-04 155 {
f8394f61c66f48 Gabor Juhos 2011-01-04 156 if (len) {
f8394f61c66f48 Gabor Juhos 2011-01-04 157 if (!nowayout) {
f8394f61c66f48 Gabor Juhos 2011-01-04 158 size_t i;
f8394f61c66f48 Gabor Juhos 2011-01-04 159
f8394f61c66f48 Gabor Juhos 2011-01-04 160 clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
f8394f61c66f48 Gabor Juhos 2011-01-04 161
f8394f61c66f48 Gabor Juhos 2011-01-04 162 for (i = 0; i != len; i++) {
f8394f61c66f48 Gabor Juhos 2011-01-04 163 char c;
f8394f61c66f48 Gabor Juhos 2011-01-04 164
f8394f61c66f48 Gabor Juhos 2011-01-04 @165 if (get_user(c, data + i))
f8394f61c66f48 Gabor Juhos 2011-01-04 166 return -EFAULT;
f8394f61c66f48 Gabor Juhos 2011-01-04 167
f8394f61c66f48 Gabor Juhos 2011-01-04 168 if (c == 'V')
f8394f61c66f48 Gabor Juhos 2011-01-04 169 set_bit(WDT_FLAGS_EXPECT_CLOSE,
f8394f61c66f48 Gabor Juhos 2011-01-04 170 &wdt_flags);
f8394f61c66f48 Gabor Juhos 2011-01-04 171 }
f8394f61c66f48 Gabor Juhos 2011-01-04 172 }
f8394f61c66f48 Gabor Juhos 2011-01-04 173
f8394f61c66f48 Gabor Juhos 2011-01-04 174 ath79_wdt_keepalive();
f8394f61c66f48 Gabor Juhos 2011-01-04 175 }
f8394f61c66f48 Gabor Juhos 2011-01-04 176
f8394f61c66f48 Gabor Juhos 2011-01-04 177 return len;
f8394f61c66f48 Gabor Juhos 2011-01-04 178 }
f8394f61c66f48 Gabor Juhos 2011-01-04 179

:::::: The code at line 165 was first introduced by commit
:::::: f8394f61c66f48b1fe9d6964ddce492d7f9a4cd9 watchdog: add driver for the Atheros AR71XX/AR724X/AR913X SoCs

:::::: TO: Gabor Juhos <juhosg@xxxxxxxxxxx>
:::::: CC: Wim Van Sebroeck <wim@xxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki