i2c: scmi: fix memory leak on invalid block length
PATCH 1/1 i2c: scmi: fix memory leak on invalid block length
From: Mohammad Shahid <[email protected]>
When the returned block length is invalid,the function returns -EPROTO directly without freeing the ACPI response buffer.
Use goto out instead, so the allocated buffer is freed before returning the error.
Signed-off-by Mohammad Shahid <[email protected]>
--- drivers/i2c/busses/i2c-scmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-scmi.c +4 -2
@@ -248,8 +248,10 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, result = -EIO ; goto out; } -if (len ==0 || len >I2C_SMBUS_BLOCK_MAX ) -return -EPROTO ; +if (len ==0 || len >I2C_SMBUS_BLOCK_MAX ) { + result = -EPROTO ; + goto out; + } data->block[0 ] = len;memcpy (data->block +1 , obj->buffer.pointer, len);break ;
Signature · 1 line
2.43.0