linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: polldev can cause crash in case of polling disabled
@ 2010-02-16 14:44 Samu Onkalo
  2010-02-16 17:50 ` Dmitry Torokhov
  0 siblings, 1 reply; 14+ messages in thread
From: Samu Onkalo @ 2010-02-16 14:44 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, Samu Onkalo

If polling is set to disabled value and polled input device
is opened and closed several times, address to workqueue will probably
change at some point. Since nothing is queued (due to polled disabled
state), content of the work struct contains pointer to the old and non-existent
workqueue. When the device is closed again, cancel_delayed_work_sync
goes crazy due to pointer to nonexisting workqueue.

In case on disabled polling, init work struct to initial value to
clean up the old values.

Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.com>
---
 drivers/input/input-polldev.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
index aa6713b..f9c8e34 100644
--- a/drivers/input/input-polldev.c
+++ b/drivers/input/input-polldev.c
@@ -88,9 +88,17 @@ static int input_open_polled_device(struct input_dev *input)
 	if (dev->open)
 		dev->open(dev);
 
-	/* Only start polling if polling is enabled */
+	/*
+	 * Only start polling if polling is enabled.
+	 * If polling is not running, clean up work struct since
+	 * pointer to just allocated WQ may have been changed since
+	 * previous use. If polling is not used, canceling of the
+	 * work goes crazy.
+	 */
 	if (dev->poll_interval > 0)
 		queue_delayed_work(polldev_wq, &dev->work, 0);
+	else
+		INIT_DELAYED_WORK(&dev->work, input_polled_device_work);
 
 	return 0;
 }
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-02-19 12:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-16 14:44 [PATCH] input: polldev can cause crash in case of polling disabled Samu Onkalo
2010-02-16 17:50 ` Dmitry Torokhov
2010-02-16 18:37   ` samu.p.onkalo
2010-02-16 21:43     ` Dmitry Torokhov
2010-02-17  8:15       ` samu.p.onkalo
2010-02-17  8:56         ` samu.p.onkalo
2010-02-17  9:47           ` Dmitry Torokhov
2010-02-17 17:03         ` Oleg Nesterov
2010-02-17 19:50           ` Dmitry Torokhov
2010-02-17 20:23             ` Oleg Nesterov
2010-02-17 20:54               ` Dmitry Torokhov
2010-02-19 12:15                 ` Oleg Nesterov
2010-02-18  6:46           ` samu.p.onkalo
2010-02-17 16:28       ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).