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

watchdog: rc32434_wdt: fix ioctl error handling

Calling return copy_to_user(...) in an ioctl will not do the right thing
if there's a pagefault: copy_to_user returns the number of bytes not
copied in this case.

Fix up watchdog/rc32434_wdt to do
return copy_to_user(...)) ? -EFAULT : 0;

instead.

Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Michael S. Tsirkin and committed by
Wim Van Sebroeck
10e7ac22 972ec351

+1 -1
+1 -1
drivers/watchdog/rc32434_wdt.c
··· 237 237 return -EINVAL; 238 238 /* Fall through */ 239 239 case WDIOC_GETTIMEOUT: 240 - return copy_to_user(argp, &timeout, sizeof(int)); 240 + return copy_to_user(argp, &timeout, sizeof(int)) ? -EFAULT : 0; 241 241 default: 242 242 return -ENOTTY; 243 243 }