Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
i2c: testunit: discard write requests while old command is running
Browse files Browse the repository at this point in the history
[ Upstream commit c116dea ]

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: b39ab96 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Wolfram Sang authored and gregkh committed Jul 5, 2024
1 parent 37bec25 commit 84ee451
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/i2c/i2c-slave-testunit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 84ee451

Please sign in to comment.