From patchwork Tue May 18 23:46:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 100640 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 o4INl0dJ020428 for ; Tue, 18 May 2010 23:47:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753804Ab0ERXq7 (ORCPT ); Tue, 18 May 2010 19:46:59 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:47856 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752565Ab0ERXq6 (ORCPT ); Tue, 18 May 2010 19:46:58 -0400 Received: by gwaa20 with SMTP id a20so1475503gwa.19 for ; Tue, 18 May 2010 16:46:57 -0700 (PDT) Received: by 10.101.136.9 with SMTP id o9mr8830383ann.103.1274226417252; Tue, 18 May 2010 16:46:57 -0700 (PDT) Received: from localhost (deeprootsystems.com [216.254.16.51]) by mx.google.com with ESMTPS id m39sm4859657ann.11.2010.05.18.16.46.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 18 May 2010 16:46:56 -0700 (PDT) From: Kevin Hilman To: linux-input@vger.kernel.org Cc: linux-omap@vger.kernel.org, Dmitry Torokhov , Michael Roth , Pavel Machek , Andrew Morton , Mike Frysinger , linux-kernel@vger.kernel.org Subject: [PATCH] touchscreen: ads7846: please don't touch free'd memory Date: Tue, 18 May 2010 16:46:53 -0700 Message-Id: <1274226413-8520-1-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.7.0.2 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, 18 May 2010 23:47:00 +0000 (UTC) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 532279c..1da2369 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -815,6 +815,9 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message) { struct ads7846 *ts = dev_get_drvdata(&spi->dev); + if (WARN_ON_ONCE(!ts)) + return 0; + spin_lock_irq(&ts->lock); ts->is_suspended = 1; @@ -833,6 +836,9 @@ static int ads7846_resume(struct spi_device *spi) { struct ads7846 *ts = dev_get_drvdata(&spi->dev); + if (WARN_ON_ONCE(!ts)) + return 0; + if (device_may_wakeup(&ts->spi->dev)) disable_irq_wake(ts->spi->irq); @@ -1231,6 +1237,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) input_free_device(input_dev); kfree(packet); kfree(ts); + dev_set_drvdata(&spi->dev, NULL); return err; } @@ -1240,6 +1247,9 @@ static int __devexit ads7846_remove(struct spi_device *spi) device_init_wakeup(&spi->dev, false); + if (WARN_ON_ONCE(!ts)) + return 0; + ads784x_hwmon_unregister(spi, ts); input_unregister_device(ts->input);