[PATCH AUTOSEL 3.18 3/4] Input: uinput - add a schedule point in uinput_inject_events()

From: Sasha Levin
Date: Mon Oct 22 2018 - 06:23:14 EST


From: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>

[ Upstream commit cecf10704899467a787975e3d94a1f0129b9688e ]

Large writes to uinput interface may cause rcu stalls. Let's add
cond_resched() to the loop to avoid this.

Reviewed-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxx>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/input/misc/uinput.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 5221450f9b57..0cc05a4cf685 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -456,6 +456,7 @@ static ssize_t uinput_inject_events(struct uinput_device *udev,

input_event(udev->dev, ev.type, ev.code, ev.value);
bytes += input_event_size();
+ cond_resched();
}

return bytes;
--
2.17.1