[PATCH 7/8] usb_pcwd: WDIOC_SETTIMEOUT: prevent preemption

From: Oliver Neukum
Date: Thu Apr 27 2023 - 09:34:22 EST


Delays between altering the watchdog
and giving the keepalive need to be controlled.
Do not allow preemption.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Oliver Neukum <oneukum@xxxxxxxx>
---
drivers/watchdog/pcwd_usb.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index 50ba88019ed6..09cae7a6ad07 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -459,10 +459,14 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,
if (get_user(new_heartbeat, p))
return -EFAULT;

- if (usb_pcwd_set_heartbeat(usb_pcwd_device, new_heartbeat))
+ preempt_disable(); /* we are on a clock now */
+ if (usb_pcwd_set_heartbeat(usb_pcwd_device, new_heartbeat)) {
+ preempt_enable();
return -EINVAL;
+ }

usb_pcwd_keepalive(usb_pcwd_device);
+ preempt_enable();
}
fallthrough;

--
2.40.0