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 <[email protected]>
---
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);
--