[PATCH 2/2] i2c: testunit: discard write requests while old command is running

Wolfram Sang posted 2 patches 1 year, 7 months ago
[PATCH 2/2] i2c: testunit: discard write requests while old command is running
Posted by Wolfram Sang 1 year, 7 months ago
When clearing registers on new write requests was added, the protection
for currently running commands was missed leading to concurrent access
to the testunit registers. Check the flag beforehand.

Fixes: b39ab96aa894 ("i2c: testunit: add support for block process calls")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/i2c-slave-testunit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/i2c-slave-testunit.c b/drivers/i2c/i2c-slave-testunit.c
index a5dcbc3c2c14..ca43e98cae1b 100644
--- a/drivers/i2c/i2c-slave-testunit.c
+++ b/drivers/i2c/i2c-slave-testunit.c
@@ -121,6 +121,9 @@ static int i2c_slave_testunit_slave_cb(struct i2c_client *client,
 		break;
 
 	case I2C_SLAVE_WRITE_REQUESTED:
+		if (test_bit(TU_FLAG_IN_PROCESS, &tu->flags))
+			return -EBUSY;
+
 		memset(tu->regs, 0, TU_NUM_REGS);
 		tu->reg_idx = 0;
 		break;
-- 
2.43.0
Re: [PATCH 2/2] i2c: testunit: discard write requests while old command is running
Posted by Wolfram Sang 1 year, 7 months ago
On Thu, Jun 27, 2024 at 01:14:48PM +0200, Wolfram Sang wrote:
> When clearing registers on new write requests was added, the protection
> for currently running commands was missed leading to concurrent access
> to the testunit registers. Check the flag beforehand.
> 
> Fixes: b39ab96aa894 ("i2c: testunit: add support for block process calls")
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to for-current, thanks!

Re: [PATCH 2/2] i2c: testunit: discard write requests while old command is running
Posted by Andi Shyti 1 year, 7 months ago
Hi Wolfram,

On Thu, Jun 27, 2024 at 01:14:48PM GMT, Wolfram Sang wrote:
> When clearing registers on new write requests was added, the protection
> for currently running commands was missed leading to concurrent access
> to the testunit registers. Check the flag beforehand.
> 
> Fixes: b39ab96aa894 ("i2c: testunit: add support for block process calls")
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>

Thanks,
Andi