Commit c116deaf authored by Wolfram Sang's avatar Wolfram Sang
Browse files

i2c: testunit: discard write requests while old command is running



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: b39ab96a ("i2c: testunit: add support for block process calls")
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
parent c422b6a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;