From patchwork Tue Feb 16 14:44:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: samu.p.onkalo@nokia.com X-Patchwork-Id: 79681 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1GEirgn022119 for ; Tue, 16 Feb 2010 14:44:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754687Ab0BPOow (ORCPT ); Tue, 16 Feb 2010 09:44:52 -0500 Received: from smtp.nokia.com ([192.100.122.233]:32473 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753206Ab0BPOow (ORCPT ); Tue, 16 Feb 2010 09:44:52 -0500 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o1GEiZug009408; Tue, 16 Feb 2010 16:44:48 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 16 Feb 2010 16:44:48 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 16 Feb 2010 16:44:47 +0200 Received: from localhost.localdomain (4fid08082.nmp.nokia.com [172.22.211.11]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o1GEifKK018475; Tue, 16 Feb 2010 16:44:42 +0200 From: Samu Onkalo To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, Samu Onkalo Subject: [PATCH] input: polldev can cause crash in case of polling disabled Date: Tue, 16 Feb 2010 16:44:41 +0200 Message-Id: <1266331481-2094-1-git-send-email-samu.p.onkalo@nokia.com> X-Mailer: git-send-email 1.6.0.4 X-OriginalArrivalTime: 16 Feb 2010 14:44:47.0470 (UTC) FILETIME=[960790E0:01CAAF16] X-Nokia-AV: Clean Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 16 Feb 2010 14:44:53 +0000 (UTC) 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; }