Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[WATCHDOG] wdt285: fix sparse warnings

The wdt285.c watchdog driver is producing a number of
sparse errors due to missing __user attributes to calls
to put_user and copy_to_user, as well as in the prototype
of watchdog_write.

wdt285.c:144:21: warning: incorrect type in argument 1 (different address spaces)
wdt285.c:144:21: expected void [noderef] <asn:1>*to
wdt285.c:144:21: got void *<noident>
wdt285.c:150:9: warning: incorrect type in initializer (different address spaces)
wdt285.c:150:9: expected int const [noderef] <asn:1>*register __p
wdt285.c:150:9: got int *<noident>
wdt285.c:159:9: warning: incorrect type in initializer (different address spaces)
wdt285.c:159:9: expected int const [noderef] <asn:1>*register __p
wdt285.c:159:9: got int *<noident>
wdt285.c:174:9: warning: incorrect type in initializer (different address spaces)
wdt285.c:174:9: expected int const [noderef] <asn:1>*register __p
wdt285.c:174:9: got int *<noident>
wdt285.c:183:12: warning: incorrect type in initializer (incompatible argument 2 (different address spaces))
wdt285.c:183:12: expected int ( *write )( ... )
wdt285.c:183:12: got int ( static [toplevel] *<noident> )( ... )

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ben Dooks and committed by
Wim Van Sebroeck
edf86c9b 7f605ac0

+8 -7
+8 -7
drivers/watchdog/wdt285.c
··· 115 115 return 0; 116 116 } 117 117 118 - static ssize_t watchdog_write(struct file *file, const char *data, 119 - size_t len, loff_t *ppos) 118 + static ssize_t watchdog_write(struct file *file, const char __user *data, 119 + size_t len, loff_t *ppos) 120 120 { 121 121 /* 122 122 * Refresh the timer. ··· 133 133 }; 134 134 135 135 static long watchdog_ioctl(struct file *file, unsigned int cmd, 136 - unsigned long arg) 136 + unsigned long arg) 137 137 { 138 138 unsigned int new_margin; 139 + int __user *int_arg = (int __user *)arg; 139 140 int ret = -ENOTTY; 140 141 141 142 switch (cmd) { 142 143 case WDIOC_GETSUPPORT: 143 144 ret = 0; 144 - if (copy_to_user((void *)arg, &ident, sizeof(ident))) 145 + if (copy_to_user((void __user *)arg, &ident, sizeof(ident))) 145 146 ret = -EFAULT; 146 147 break; 147 148 148 149 case WDIOC_GETSTATUS: 149 150 case WDIOC_GETBOOTSTATUS: 150 - ret = put_user(0, (int *)arg); 151 + ret = put_user(0, int_arg); 151 152 break; 152 153 153 154 case WDIOC_KEEPALIVE: ··· 157 156 break; 158 157 159 158 case WDIOC_SETTIMEOUT: 160 - ret = get_user(new_margin, (int *)arg); 159 + ret = get_user(new_margin, int_arg); 161 160 if (ret) 162 161 break; 163 162 ··· 172 171 watchdog_ping(); 173 172 /* Fall */ 174 173 case WDIOC_GETTIMEOUT: 175 - ret = put_user(soft_margin, (int *)arg); 174 + ret = put_user(soft_margin, int_arg); 176 175 break; 177 176 } 178 177 return ret;