drivers/rtc/rtc-m41t80.c:736:21: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Tue Nov 03 2020 - 06:19:29 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b7cbaf59f62f8ab8f157698f9e31642bff525bd0
commit: e5fc436f06eef54ef512ea55a9db8eb9f2e76959 sparse: use static inline for __chk_{user,io}_ptr()
date: 9 weeks ago
config: sh-randconfig-s032-20201031 (attached as .config)
compiler: sh4-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-76-gf680124b-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=sh

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/rtc/rtc-m41t80.c:736:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user * @@
drivers/rtc/rtc-m41t80.c:736:21: sparse: expected int const *__gu_addr
drivers/rtc/rtc-m41t80.c:736:21: sparse: got int [noderef] __user *
>> drivers/rtc/rtc-m41t80.c:736:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
>> drivers/rtc/rtc-m41t80.c:736:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/rtc/rtc-m41t80.c:736:21: sparse: got int const *__gu_addr

vim +736 drivers/rtc/rtc-m41t80.c

617780d290bd6e Atsushi Nemoto 2007-07-17 702
617780d290bd6e Atsushi Nemoto 2007-07-17 703 /**
617780d290bd6e Atsushi Nemoto 2007-07-17 704 * wdt_ioctl:
617780d290bd6e Atsushi Nemoto 2007-07-17 705 * @file: file handle to the device
617780d290bd6e Atsushi Nemoto 2007-07-17 706 * @cmd: watchdog command
617780d290bd6e Atsushi Nemoto 2007-07-17 707 * @arg: argument pointer
617780d290bd6e Atsushi Nemoto 2007-07-17 708 *
617780d290bd6e Atsushi Nemoto 2007-07-17 709 * The watchdog API defines a common set of functions for all watchdogs
617780d290bd6e Atsushi Nemoto 2007-07-17 710 * according to their available features. We only actually usefully support
617780d290bd6e Atsushi Nemoto 2007-07-17 711 * querying capabilities and current status.
617780d290bd6e Atsushi Nemoto 2007-07-17 712 */
55929332c92e5d Arnd Bergmann 2010-04-27 713 static int wdt_ioctl(struct file *file, unsigned int cmd,
617780d290bd6e Atsushi Nemoto 2007-07-17 714 unsigned long arg)
617780d290bd6e Atsushi Nemoto 2007-07-17 715 {
617780d290bd6e Atsushi Nemoto 2007-07-17 716 int new_margin, rv;
617780d290bd6e Atsushi Nemoto 2007-07-17 717 static struct watchdog_info ident = {
617780d290bd6e Atsushi Nemoto 2007-07-17 718 .options = WDIOF_POWERUNDER | WDIOF_KEEPALIVEPING |
617780d290bd6e Atsushi Nemoto 2007-07-17 719 WDIOF_SETTIMEOUT,
617780d290bd6e Atsushi Nemoto 2007-07-17 720 .firmware_version = 1,
617780d290bd6e Atsushi Nemoto 2007-07-17 721 .identity = "M41T80 WTD"
617780d290bd6e Atsushi Nemoto 2007-07-17 722 };
617780d290bd6e Atsushi Nemoto 2007-07-17 723
617780d290bd6e Atsushi Nemoto 2007-07-17 724 switch (cmd) {
617780d290bd6e Atsushi Nemoto 2007-07-17 725 case WDIOC_GETSUPPORT:
617780d290bd6e Atsushi Nemoto 2007-07-17 726 return copy_to_user((struct watchdog_info __user *)arg, &ident,
617780d290bd6e Atsushi Nemoto 2007-07-17 727 sizeof(ident)) ? -EFAULT : 0;
617780d290bd6e Atsushi Nemoto 2007-07-17 728
617780d290bd6e Atsushi Nemoto 2007-07-17 729 case WDIOC_GETSTATUS:
617780d290bd6e Atsushi Nemoto 2007-07-17 730 case WDIOC_GETBOOTSTATUS:
617780d290bd6e Atsushi Nemoto 2007-07-17 731 return put_user(boot_flag, (int __user *)arg);
617780d290bd6e Atsushi Nemoto 2007-07-17 732 case WDIOC_KEEPALIVE:
617780d290bd6e Atsushi Nemoto 2007-07-17 733 wdt_ping();
617780d290bd6e Atsushi Nemoto 2007-07-17 734 return 0;
617780d290bd6e Atsushi Nemoto 2007-07-17 735 case WDIOC_SETTIMEOUT:
617780d290bd6e Atsushi Nemoto 2007-07-17 @736 if (get_user(new_margin, (int __user *)arg))
617780d290bd6e Atsushi Nemoto 2007-07-17 737 return -EFAULT;
617780d290bd6e Atsushi Nemoto 2007-07-17 738 /* Arbitrary, can't find the card's limits */
617780d290bd6e Atsushi Nemoto 2007-07-17 739 if (new_margin < 1 || new_margin > 124)
617780d290bd6e Atsushi Nemoto 2007-07-17 740 return -EINVAL;
617780d290bd6e Atsushi Nemoto 2007-07-17 741 wdt_margin = new_margin;
617780d290bd6e Atsushi Nemoto 2007-07-17 742 wdt_ping();
c3e04915b8674a Gustavo A. R. Silva 2018-10-04 743 /* Fall through */
617780d290bd6e Atsushi Nemoto 2007-07-17 744 case WDIOC_GETTIMEOUT:
617780d290bd6e Atsushi Nemoto 2007-07-17 745 return put_user(wdt_margin, (int __user *)arg);
617780d290bd6e Atsushi Nemoto 2007-07-17 746
617780d290bd6e Atsushi Nemoto 2007-07-17 747 case WDIOC_SETOPTIONS:
617780d290bd6e Atsushi Nemoto 2007-07-17 748 if (copy_from_user(&rv, (int __user *)arg, sizeof(int)))
617780d290bd6e Atsushi Nemoto 2007-07-17 749 return -EFAULT;
617780d290bd6e Atsushi Nemoto 2007-07-17 750
617780d290bd6e Atsushi Nemoto 2007-07-17 751 if (rv & WDIOS_DISABLECARD) {
a737e835e5769e Joe Perches 2015-04-16 752 pr_info("disable watchdog\n");
617780d290bd6e Atsushi Nemoto 2007-07-17 753 wdt_disable();
617780d290bd6e Atsushi Nemoto 2007-07-17 754 }
617780d290bd6e Atsushi Nemoto 2007-07-17 755
617780d290bd6e Atsushi Nemoto 2007-07-17 756 if (rv & WDIOS_ENABLECARD) {
a737e835e5769e Joe Perches 2015-04-16 757 pr_info("enable watchdog\n");
617780d290bd6e Atsushi Nemoto 2007-07-17 758 wdt_ping();
617780d290bd6e Atsushi Nemoto 2007-07-17 759 }
617780d290bd6e Atsushi Nemoto 2007-07-17 760
617780d290bd6e Atsushi Nemoto 2007-07-17 761 return -EINVAL;
617780d290bd6e Atsushi Nemoto 2007-07-17 762 }
617780d290bd6e Atsushi Nemoto 2007-07-17 763 return -ENOTTY;
617780d290bd6e Atsushi Nemoto 2007-07-17 764 }
617780d290bd6e Atsushi Nemoto 2007-07-17 765

:::::: The code at line 736 was first introduced by commit
:::::: 617780d290bd6eb2b260928c6acff5b7c6084154 rtc: watchdog support for rtc-m41t80 driver

:::::: TO: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip