mctp i2c: don't count unused / invalid keys for flow release
authorJeremy Kerr <jk@codeconstruct.com.au>
Thu, 10 Nov 2022 05:31:35 +0000 (13:31 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 12 Nov 2022 04:13:27 +0000 (20:13 -0800)
commit9cbd48d5fa14e4c65f8580de16686077f7cea02b
treea64ba8233b1da9810f56c3ff7bc477d118a3ae5a
parent0834ced65a6a1eaa10d0b319b685879a671b29aa
mctp i2c: don't count unused / invalid keys for flow release

We're currently hitting the WARN_ON in mctp_i2c_flow_release:

    if (midev->release_count > midev->i2c_lock_count) {
        WARN_ONCE(1, "release count overflow");

This may be hit if we expire a flow before sending the first packet it
contains - as we will not be pairing the increment of release_count
(performed on flow release) with the i2c lock operation (only
performed on actual TX).

To fix this, only release a flow if we've encountered it previously (ie,
dev_flow_state does not indicate NEW), as we will mark the flow as
ACTIVE at the same time as accounting for the i2c lock operation. We
also need to add an INVALID flow state, to indicate when we've done the
release.

Fixes: f5b8abf9fc3d ("mctp i2c: MCTP I2C binding driver")
Reported-by: Jian Zhang <zhangjian.3032@bytedance.com>
Tested-by: Jian Zhang <zhangjian.3032@bytedance.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Link: https://lore.kernel.org/r/20221110053135.329071-1-jk@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/mctp/mctp-i2c.c