trf7970a_switch_rf_on() bumps the runtime PM usage counter before validating the state and before initialising the chip. Neither the incorrect-state path nor the trf7970a_init() failure path drops that reference, and none of the three callers balance it either, so the usage counter stays elevated. Use pm_runtime_resume_and_get() so that a failed resume does not leave the counter incremented, and release the reference with the same mark-last-busy/put-autosuspend pair that trf7970a_switch_rf_off() uses when either of the subsequent steps fails. Fixes: e6403b7c756f ("NFC: trf7970a: Add pm_runtime support") Cc: stable@vger.kernel.org Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex Signed-off-by: Wentao Liang --- drivers/nfc/trf7970a.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index ddfc58c29964..7de590485657 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -1150,23 +1150,31 @@ static int trf7970a_switch_rf_on(struct trf7970a *trf) dev_dbg(trf->dev, "Switching rf on\n"); - pm_runtime_get_sync(trf->dev); + ret = pm_runtime_resume_and_get(trf->dev); + if (ret) + return ret; if (trf->state != TRF7970A_ST_RF_OFF) { /* Power on, RF off */ dev_err(trf->dev, "%s - Incorrect state: %d\n", __func__, trf->state); - return -EINVAL; + ret = -EINVAL; + goto err_put; } ret = trf7970a_init(trf); if (ret) { dev_err(trf->dev, "%s - Can't initialize: %d\n", __func__, ret); - return ret; + goto err_put; } trf->state = TRF7970A_ST_IDLE; return 0; + +err_put: + pm_runtime_mark_last_busy(trf->dev); + pm_runtime_put_autosuspend(trf->dev); + return ret; } static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on) -- 2.34.1