Skip to content

Commit

Permalink
Input: stmfts - do not leave device disabled in stmfts_input_open
Browse files Browse the repository at this point in the history
[ Upstream commit 5f76955 ]

The commit 26623ee attempted to deal with potential leak of runtime
PM counter when opening the touchscreen device, however it ended up
erroneously dropping the counter in the case of successfully enabling the
device.

Let's address this by using pm_runtime_resume_and_get() and then executing
pm_runtime_put_sync() only when we fail to send "sense on" command to the
device.

Fixes: 26623ee ("Input: stmfts - fix reference leak in stmfts_input_open")
Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
dtor authored and gregkh committed Jun 9, 2022
1 parent fc0750e commit baf86af
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/input/touchscreen/stmfts.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,15 @@ static int stmfts_input_open(struct input_dev *dev)
struct stmfts_data *sdata = input_get_drvdata(dev);
int err;

err = pm_runtime_get_sync(&sdata->client->dev);
if (err < 0)
goto out;
err = pm_runtime_resume_and_get(&sdata->client->dev);
if (err)
return err;

err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON);
if (err)
goto out;
if (err) {
pm_runtime_put_sync(&sdata->client->dev);
return err;
}

mutex_lock(&sdata->mutex);
sdata->running = true;
Expand All @@ -366,9 +368,7 @@ static int stmfts_input_open(struct input_dev *dev)
"failed to enable touchkey\n");
}

out:
pm_runtime_put_noidle(&sdata->client->dev);
return err;
return 0;
}

static void stmfts_input_close(struct input_dev *dev)
Expand Down

0 comments on commit baf86af

Please sign in to comment.