blob: 36ecd86a2609acfdd1a8e13d1bfd1af8e0e6b9c8 [file] [log] [blame]
From aef36d8fa9561689ff503d3873a2cfbeabff14f2 Mon Sep 17 00:00:00 2001
From: Fabien Parent <>
Date: Fri, 18 Oct 2019 19:32:13 +0200
Subject: [PATCH] i2c: mt65xx: fix NULL ptr dereference
commit 62931ac2f9015ea38d80494ec37658ab3df6a6d7 upstream.
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.
Fixes: abf4923e97c3 ("i2c: mediatek: disable zero-length transfers for mt8183")
Signed-off-by: Fabien Parent <>
Reviewed-by: Cengiz Can <>
Reviewed-by: Hsin-Yi Wang <>
Tested-by: Ulrich Hecht <>
Signed-off-by: Wolfram Sang <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index 29eae1bf4f86..2152ec5f535c 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -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 |