All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pan Xinhui <xinhuix.pan@intel.com>
To: linux-kernel@vger.kernel.org
Cc: dmitry.torokhov@gmail.com, nick.dyer@itdev.co.uk,
	miletus@chromium.org, bleung@chromium.org, djkurtz@chromium.org,
	mnipxh@163.com
Subject: [PATCH] touchscreen:atmel_mxt_ts: suspend/resume cause panic if input_dev fails to init
Date: Fri, 24 Apr 2015 11:53:04 +0800	[thread overview]
Message-ID: <5539BE20.7020807@intel.com> (raw)

input_dev may be NULL if mxt_initialize_input_device fails. But pm ops is still available and suspend/resume assume
input_dev is not NULL. To fix this issue, we add a check if (!input_dev).

Signed-off-by: xinhui.pan <xinhuix.pan@intel.com>
---
  drivers/input/touchscreen/atmel_mxt_ts.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 2875ddf..a39e0dc 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -2500,6 +2500,9 @@ static int __maybe_unused mxt_suspend(struct device *dev)
  	struct mxt_data *data = i2c_get_clientdata(client);
  	struct input_dev *input_dev = data->input_dev;
  
+	if (!input_dev)
+		return 0;
+
  	mutex_lock(&input_dev->mutex);
  
  	if (input_dev->users)
@@ -2516,6 +2519,9 @@ static int __maybe_unused mxt_resume(struct device *dev)
  	struct mxt_data *data = i2c_get_clientdata(client);
  	struct input_dev *input_dev = data->input_dev;
  
+	if (!input_dev)
+		return 0;
+
  	mxt_soft_reset(data);
  
  	mutex_lock(&input_dev->mutex);
-- 

                 reply	other threads:[~2015-04-23  3:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5539BE20.7020807@intel.com \
    --to=xinhuix.pan@intel.com \
    --cc=bleung@chromium.org \
    --cc=djkurtz@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miletus@chromium.org \
    --cc=mnipxh@163.com \
    --cc=nick.dyer@itdev.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.