Skip to contentSkip to conversation

i2c: qcom-geni: release runtime PM reference when set_rate fails

PATCH Applied Rahul Pon 3 participants 3 messages Sep 30 – Oct 5

Subsystems (3)
lore
Share & tools
lore

Rahul Pon

author
#0 lore raw

PATCH 1/1 i2c: qcom-geni: release runtime PM reference when set_rate fails

geni_i2c_xfer() takes a runtime-PM reference with pm_runtime_get_sync() and then returns directly if the set_rate() callback fails, leaking the reference and keeping the controller resumed for good. Route that error through the existing cleanup path, which drops the reference and resets the transfer state.

Found by code review; compile-tested with arm64 defconfig plus ACPI and W=1.

Fixes 10e74f4c5046 ("i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms")
Assisted-by LLM
---
 drivers/i2c/busses/i2c-qcom-geni.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-qcom-geni.c +2 -1
index 6a39e21d5e..ed6495ef81 100644
@@ -1003,13 +1003,14 @@ static int geni_i2c_xfer(struct i2c_adapter *adap,
 
 	ret = gi2c->dev_data->set_rate(&gi2c->se, gi2c->clk_freq_out);
 	if (ret)
-		return ret;
+		goto out_pm;
 
 	if (gi2c->gpi_mode)
 		ret = geni_i2c_gpi_xfer(gi2c, msgs, num);
 	else
 		ret = geni_i2c_fifo_xfer(gi2c, msgs, num);
 
+out_pm:
 	pm_runtime_put_autosuspend(gi2c->se.dev);
 	gi2c->cur = NULL;
 	gi2c->err = 0;

base-commit: 551c722f40809618230001baccf219193e22fc5a

Signature · 1 line
2.53.0
maintainer Applied
#1 lore raw

Hi Rahul,

Quoted 6 lines · Rahul Pon

geni_i2c_xfer() takes a runtime-PM reference with pm_runtime_get_sync() and then returns directly if the set_rate() callback fails, leaking the reference and keeping the controller resumed for good. Route that error through the existing cleanup path, which drops the reference and resets the transfer state.

Quoted 6 lines

Found by code review; compile-tested with arm64 defconfig plus ACPI and W=1.

Fixes 10e74f4c5046 ("i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms")
Assisted-by LLM

pushed to i2c/i2c-fixes-2.

Thanks,
Andi

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Rahul Pon
Quoted 6 lines · Rahul Pon

geni_i2c_xfer() takes a runtime-PM reference with pm_runtime_get_sync() and then returns directly if the set_rate() callback fails, leaking the reference and keeping the controller resumed for good. Route that error through the existing cleanup path, which drops the reference and resets the transfer state.

Quoted 7 lines

Found by code review; compile-tested with arm64 defconfig plus ACPI and W=1.

Fixes 10e74f4c5046 ("i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms")
Assisted-by LLM

---