* [PATCH] i2c: scmi: fix memory leak on invalid block length
@ 2026-11-20 5:41 mdshahid03
0 siblings, 0 replies; only message in thread
From: mdshahid03 @ 2026-11-20 5:41 UTC (permalink / raw)
To: Andi Shyti; +Cc: linux-i2c, linux-kernel, Mohammad Shahid
From: Mohammad Shahid <mdshahid03@gmail.com>
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 <mdshahid03@gmail.com>
---
drivers/i2c/busses/i2c-scmi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
index 37442c9ee222..b65771d31a28 100644
--- a/drivers/i2c/busses/i2c-scmi.c
+++ b/drivers/i2c/busses/i2c-scmi.c
@@ -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;
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-20 5:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 5:41 [PATCH] i2c: scmi: fix memory leak on invalid block length mdshahid03
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®