Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1835698ybn; Thu, 26 Sep 2019 02:59:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRAgWdZy1MVo9WyYcl0E9fKAlaS0fkyshqXE6fkAz7tK9Fo4c0hPFrmsN2XIq0PR7L9xtr X-Received: by 2002:a17:906:b2d4:: with SMTP id cf20mr2246827ejb.152.1569491967901; Thu, 26 Sep 2019 02:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569491967; cv=none; d=google.com; s=arc-20160816; b=t8fdK0I/sta1xNnJvO2zr+rB66wvkXYL+BlsZAOAXbA2d3M+kGPLkr2jfQg1bRq68Z 6L2elFG8vU5DiY20Kw5NqatNuQDRiL9z/wsAqEMeunZlShhcZfBdfN7FqPe01ZivJprI Gv1m2tjj6/6e3z1FOcG7gK5d8ZWuH+2AQuuWIejwOc510JdkKwIzXwfMrIVX4s3LvC5E u/BxUV5cOaStOh9kEF3LASoqI4PQrgfqNLWytMZaAAa2JZTCQGTiJ8z3zyZnHOs16+/N D6PiPEbyjRcqxEyseQbvNiSb06CL5jn4qTNOL2NznA2/utso5Ex9Qx/sb59EyGjdLoKz moQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AcBsCzwhp5Ecgxfu1Yf/yNSTuRVO8fFdckSjieoTLBs=; b=NnEyT5ugz9vcFfs9X1RyaAiUdh5fkPGwAYT0icRkimiQrpNH2IAC8Ax39EbSKXu0l5 BMKi1T+DAKluj8IcMNJRP7fmBXL0/p9aPhLbeOSUmQT6a3XJe9iwSFWGMz5XbqJYFm5B GnvzoW9BI4SpMwNc/OqNzFCgHYVP92wqZD0D0tOzxM7KsldP3qj6vCF44gURTagEctCU lFKAv2ZmPpnAJYrbs0o1LgOmza7DtTRB0ZTSEk/MqFV2eJi3JmQXuBTAivA3B4udlYX6 xeGybTlCAxcqk6jlsnIuG0XgMvBirnsgzcJ4Tvt9PnWah2zZpxef10A7JiOfYlxy8tel HHlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=dOzuI9mJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si1036755edb.425.2019.09.26.02.59.04; Thu, 26 Sep 2019 02:59:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=dOzuI9mJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393161AbfIYUbT (ORCPT + 99 others); Wed, 25 Sep 2019 16:31:19 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42412 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387768AbfIYUbT (ORCPT ); Wed, 25 Sep 2019 16:31:19 -0400 Received: by mail-wr1-f67.google.com with SMTP id n14so8411972wrw.9 for ; Wed, 25 Sep 2019 13:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AcBsCzwhp5Ecgxfu1Yf/yNSTuRVO8fFdckSjieoTLBs=; b=dOzuI9mJG7MNkBkGgMGYhShhE5duhtiVQDyWLneLxX5wD/HCWf9T/PGCnLnPzC7wtc ysS3Th4+kQaByGMbqsOJTgU9iown1CZdT89pHVI0AwdYL8iFDKcrSGBjpJLG5UVdC/Z5 eFEL4LYNjIxiH8xHZSo6ggGvIjxXX0eE8hVW8ghYYZYge090LkWEtqou4uIwMC+Q6C7K BmI6qzs0PsJPxUaEiJH3kQJ+Rut1XEYojN4XokuuEIzUqBoZdypscGa3T0t7AJulGOCi pQeAI/Uc1o44hsSpr1OWt2THVPdcK3Q0ilf9Qd1CykPt2J7mq2nyU7AkflhRneuODZeh d2HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AcBsCzwhp5Ecgxfu1Yf/yNSTuRVO8fFdckSjieoTLBs=; b=FBCvjUvXr/7c/ClUbKUgRQGtTzFNgzTUZaEkTwvbrcK0EcMnCwP6GVK6igjqXcfoBw SLSO5rkAWgJQgrn1YI7tibNPVPC6EALRoaFGU5pf0YzjUpvNhaCfTmWCLNP72reh0msU BWhfvgsU95bJ9Ccm0XrSiIC3C9Fi3Fc31z74fpCGf0Q9p122PozTDQj/rJh6KD93a/0N nq6LI/G722QPfowQaN9nXvfTc9CMhxNzVsHhKrPuMiKuU2F3gfYodVpQWQ6Iupxys0lC kyr+ZUiz8VX6YFmMYP2w2RX3QCZAARFx6evp8Cz/YH/p0XaGd58aKIOBNn4qECKTazki UFog== X-Gm-Message-State: APjAAAU9t2xbw5eJgo7fQnQx1apzlI3QIlOEjj2rovundPMDfHyvfomq 3ePMwYQvpLrvtdJcYppJuMzO1hK9B+U= X-Received: by 2002:adf:cc87:: with SMTP id p7mr142508wrj.43.1569443477086; Wed, 25 Sep 2019 13:31:17 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ecba:5540:2c05:40e4:899d:aef0]) by smtp.gmail.com with ESMTPSA id j1sm301348wrg.24.2019.09.25.13.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 13:31:16 -0700 (PDT) From: Fabien Parent To: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: matthias.bgg@gmail.com, wsa@the-dreams.de, qii.wang@mediatek.com, drinkcat@chromium.org, hsinyi@chromium.org, tglx@linutronix.de, Fabien Parent Subject: [PATCH] i2c: i2c-mt65xx: fix NULL ptr dereference Date: Wed, 25 Sep 2019 22:31:13 +0200 Message-Id: <20190925203113.6972-1-fparent@baylibre.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 check on the quirk pointer before dereferencing it. Fixes: abf4923e97c3 ("i2c: mediatek: disable zero-length transfers for mt8183") Signed-off-by: Fabien Parent --- drivers/i2c/busses/i2c-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 29eae1bf4f86..ec00fc6af9ae 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 (adap->quirks && adap->quirks->flags & I2C_AQ_NO_ZERO_LEN) return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK); else -- 2.23.0