[PATCH] NFC: trf7970a: Fix runtime PM leak in trf7970a_switch_rf_on()
From: Wentao Liang
Date: Thu Sep 17 2026 - 08:34:11 EST
pm_runtime_get_sync() unconditionally increments the runtime PM usage
counter, so the reference taken at the top of trf7970a_switch_rf_on()
has to be dropped on every exit path. The two error paths return
without doing so, and since the chip is left in TRF7970A_ST_RF_OFF they
are not balanced by trf7970a_switch_rf_off() either.
Release the reference the same way trf7970a_switch_rf_off() does.
Fixes: e6403b7c756f9 ("NFC: trf7970a: Add pm_runtime support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/nfc/trf7970a.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 08c27bb438b5..07bc336c6505 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -1155,12 +1155,14 @@ static int trf7970a_switch_rf_on(struct trf7970a *trf)
if (trf->state != TRF7970A_ST_RF_OFF) { /* Power on, RF off */
dev_err(trf->dev, "%s - Incorrect state: %d\n", __func__,
trf->state);
+ pm_runtime_put_autosuspend(trf->dev);
return -EINVAL;
}
ret = trf7970a_init(trf);
if (ret) {
dev_err(trf->dev, "%s - Can't initialize: %d\n", __func__, ret);
+ pm_runtime_put_autosuspend(trf->dev);
return ret;
}
--
2.34.1