i2c: cadence: cdns_i2c_master_xfer(): Fix runtime PM leak on error path
Subsystems (2)
PATCH 1/2 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.
--- drivers/i2c/busses/i2c-cadence.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-cadence.c +4 -2
@@ -834,8 +834,10 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,#if IS_ENABLED (CONFIG_I2C_SLAVE )/* Check i2c operating mode and switch if possible */ if (id->dev_mode ==CDNS_I2C_MODE_SLAVE ) { -if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) -return -EAGAIN ; +if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) { + ret = -EAGAIN ; + goto out; + }/* Set mode to master */ cdns_i2c_set_mode (CDNS_I2C_MODE_MASTER , id);
Signature · 1 line
2.30.2
PATCH 2/2 i2c: xiic: xiic_xfer(): Fix runtime PM leak on error path
The xiic_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.
--- drivers/i2c/busses/i2c-xiic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-xiic.c +3 -1
@@ -1164,7 +1164,7 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) err =xiic_start_xfer (i2c, msgs, num);if (err <0 ) {dev_err (adap->dev.parent,"Error xiic_start_xfer\n" ); -return err; + goto out; } err =wait_for_completion_timeout (&i2c->completion,XIIC_XFER_TIMEOUT );
@@ -1178,6 +1178,8 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) err = (i2c->state ==STATE_DONE ) ? num : -EIO ; }mutex_unlock (&i2c->lock); + +out:pm_runtime_mark_last_busy (i2c->dev);pm_runtime_put_autosuspend (i2c->dev);return err;
Signature · 1 line
2.30.2
Re: [PATCH 2/2] i2c: xiic: xiic_xfer(): Fix runtime PM leak on error path
Quoted 27 lines · Lars-Peter Clausen
The
xiic_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 fdacc3c7405d ("i2c: xiic: Switch from waitqueue to completion")Signed-off-by Lars-Peter Clausen <[email protected]>--- drivers/i2c/busses/i2c-xiic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-xiic.c +1
-1@@ -1164,7 +1164,7 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) err =xiic_start_xfer (i2c, msgs, num);if (err <0 ) {dev_err (adap->dev.parent,"Error xiic_start_xfer\n" ); -return err; + goto out; } err =wait_for_completion_timeout (&i2c->completion,XIIC_XFER_TIMEOUT );
drivers/i2c/busses/i2c-xiic.c static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) · line 1185
Quoted 8 lines
drivers/i2c/busses/i2c-xiic.c +2
-0@@ -1178,6 +1178,8 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) err = (i2c->state ==STATE_DONE ) ? num : -EIO ; }mutex_unlock (&i2c->lock); + +out:pm_runtime_mark_last_busy (i2c->dev);pm_runtime_put_autosuspend (i2c->dev);return err;
Thanks,
Michal
Wolfram Sang
AppliedRe: [PATCH 2/2] i2c: xiic: xiic_xfer(): Fix runtime PM leak on error path
In reply to Lars-Peter ClausenQuoted 9 lines · Lars-Peter Clausen
The
xiic_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 fdacc3c7405d ("i2c: xiic: Switch from waitqueue to completion")Signed-off-by Lars-Peter Clausen <[email protected]>
Applied to for-current, thanks!
Quoted 20 lines · Lars-Peter Clausen
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 1a351b10b967 ("i2c: cadence: Added slave support")Signed-off-by Lars-Peter Clausen <[email protected]>--- drivers/i2c/busses/i2c-cadence.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-cadence.c +0
-0@@ -834,8 +834,10 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,#if IS_ENABLED (CONFIG_I2C_SLAVE )/* Check i2c operating mode and switch if possible */
drivers/i2c/busses/i2c-cadence.c static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 843
Quoted 10 lines
drivers/i2c/busses/i2c-cadence.c +4
-2if (id->dev_mode ==CDNS_I2C_MODE_SLAVE ) { -if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) -return -EAGAIN ; +if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) { + ret = -EAGAIN ; + goto out; + }/* Set mode to master */ cdns_i2c_set_mode (CDNS_I2C_MODE_MASTER , id);
Thanks,
Michal
Wolfram Sang
AppliedQuoted 9 lines · Lars-Peter Clausen
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 1a351b10b967 ("i2c: cadence: Added slave support")Signed-off-by Lars-Peter Clausen <[email protected]>
Applied to for-current, thanks!
Quoted 6 lines · Wolfram Sang
Quoted 5 lines · Lars-Peter Clausen
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.
Quoted 6 lines
Quoted 4 lines
Make sure that this error path also releases the runtime PM reference.
Fixes 1a351b10b967 ("i2c: cadence: Added slave support")Signed-off-by Lars-Peter Clausen <[email protected]>Applied to for-current, thanks!
Sorry, I missed 6.3. I'll merge this into my PR for 6.4-rc1.