Skip to content

Commit 5f76955

Browse files
committed
Input: stmfts - do not leave device disabled in stmfts_input_open
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>
1 parent cee409b commit 5f76955

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/input/touchscreen/stmfts.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,15 @@ static int stmfts_input_open(struct input_dev *dev)
337337
struct stmfts_data *sdata = input_get_drvdata(dev);
338338
int err;
339339

340-
err = pm_runtime_get_sync(&sdata->client->dev);
341-
if (err < 0)
342-
goto out;
340+
err = pm_runtime_resume_and_get(&sdata->client->dev);
341+
if (err)
342+
return err;
343343

344344
err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON);
345-
if (err)
346-
goto out;
345+
if (err) {
346+
pm_runtime_put_sync(&sdata->client->dev);
347+
return err;
348+
}
347349

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

369-
out:
370-
pm_runtime_put_noidle(&sdata->client->dev);
371-
return err;
371+
return 0;
372372
}
373373

374374
static void stmfts_input_close(struct input_dev *dev)

0 commit comments

Comments
 (0)