i2c: i2c-mt65xx: fix NULL ptr dereference
PATCH v2 1/1 i2c: i2c-mt65xx: fix NULL ptr dereference
Since commit abf4923e97c3 ("i2c: mediatek: disable zero-length transfers for mt8183"), there is a NULL pointer dereference for all the SoCs that don't have any quirk. mtk_i2c_functionality is not checking that the quirks pointer is not NULL before starting to use it.
This commit add a call to i2c_check_quirks which will check whether the quirks pointer is set, and if so will check if the IP has the NO_ZERO_LEN quirk.
---
v2:
* use i2c_check_quirks to check the quirks
--- drivers/i2c/busses/i2c-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-mt65xx.c +1 -1
@@ -875,7 +875,7 @@ static irqreturn_t mtk_i2c_irq(int irqno, void *dev_id)static u32 mtk_i2c_functionality (struct i2c_adapter *adap) { -if (adap->quirks->flags &I2C_AQ_NO_ZERO_LEN ) +if (i2c_check_quirks (adap,I2C_AQ_NO_ZERO_LEN ))return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK );else
Signature · 1 line
2.23.0
Quoted 2 lines · Fabien Parent
Fixes abf4923e97c3 ("i2c: mediatek: disable zero-length transfers for mt8183")Signed-off-by Fabien Parent <[email protected]>
Hsin-Yi Wang
Reviewed-byQuoted 7 lines · Cengiz Can
Quoted 3 lines · Fabien Parent
Fixes abf4923e97c3 ("i2c: mediatek: disable zero-length transfers formt8183")
Signed-off-by Fabien Parent <[email protected]>Reviewed-by Cengiz Can <[email protected]>
Thanks!
Quoted 9 lines · Fabien Parent
Since commit
abf4923e97c3("i2c: mediatek: disable zero-length transfers for mt8183"), there is a NULL pointer dereference for all the SoCs that don't have any quirk.mtk_i2c_functionalityis not checking that the quirks pointer is not NULL before starting to use it.
Quoted 6 lines
This commit add a call to
i2c_check_quirkswhich will check whether the quirks pointer is set, and if so will check if the IP has theNO_ZERO_LENquirk.Fixes abf4923e97c3 ("i2c: mediatek: disable zero-length transfers for mt8183")Signed-off-by Fabien Parent <[email protected]>
Thank you! Tested successfully on Acer R13 Chromebook (mt8173).
CU
Uli