Skip to content

Commit ae1664f

Browse files
larsclausenwsakernel
authored andcommitted
i2c: cadence: cdns_i2c_master_xfer(): Fix runtime PM leak on error path
The cdns_i2c_master_xfer() function gets a runtime PM reference when the function is entered. This reference is released when the function is exited. There is currently one error path where the function exits directly, which leads to a leak of the runtime PM reference. Make sure that this error path also releases the runtime PM reference. Fixes: 1a351b1 ("i2c: cadence: Added slave support") Signed-off-by: Lars-Peter Clausen <[email protected]> Reviewed-by: Michal Simek <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 6a8f57a commit ae1664f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/i2c/busses/i2c-cadence.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,10 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
827827
#if IS_ENABLED(CONFIG_I2C_SLAVE)
828828
/* Check i2c operating mode and switch if possible */
829829
if (id->dev_mode == CDNS_I2C_MODE_SLAVE) {
830-
if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE)
831-
return -EAGAIN;
830+
if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE) {
831+
ret = -EAGAIN;
832+
goto out;
833+
}
832834

833835
/* Set mode to master */
834836
cdns_i2c_set_mode(CDNS_I2C_MODE_MASTER, id);

0 commit comments

Comments
 (0)