From patchwork Wed May 26 19:43:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 12282645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AA14C47082 for ; Wed, 26 May 2021 19:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07C06613D8 for ; Wed, 26 May 2021 19:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234141AbhEZTok (ORCPT ); Wed, 26 May 2021 15:44:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:38650 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231924AbhEZToj (ORCPT ); Wed, 26 May 2021 15:44:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1622058186; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PDr39Ej3qpXf1ztiFP8D4NcikT1U25GcUHsEX5q8P2Q=; b=WPdW5C/mFutCugh4ULAVqQeh1IXJQuKMdVt3cTawXj10HXFKTrDkv792PMVP0fAK1ojyzl gG33wErSQyJV8r9Jd85lwcv9DonJRw35MvSX7rEfWuo3pGm92OdWg4fkj7B00OdNObmiOP YK5VtRXqU7jSMGIvFWX5IKVsOzvd2dc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1622058186; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PDr39Ej3qpXf1ztiFP8D4NcikT1U25GcUHsEX5q8P2Q=; b=Dyko30elgdOA/4/L7YoOPCqGxB6ndErjplaeRLXsmTx5HZrpcACU52cDNXzqXCUJ9a4+jD lsWQvn1c3xQuRQDA== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4196BAB71; Wed, 26 May 2021 19:43:06 +0000 (UTC) From: Takashi Iwai To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] Input: elants_i2c - Fix NULL dereference at probing Date: Wed, 26 May 2021 21:43:01 +0200 Message-Id: <20210526194301.28780-1-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The recent change in elants_i2c driver to support more chips introduced a regression leading to Oops at probing. The driver reads id->driver_data, but the id may be NULL depending on the device type the driver gets bound. Add a NULL check and falls back to the default EKTH3500. Fixes: 9517b95bdc46 ("Input: elants_i2c - add support for eKTF3624") BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1186454 Cc: Signed-off-by: Takashi Iwai --- drivers/input/touchscreen/elants_i2c.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 17540bdb1eaf..172a6951cead 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -1396,7 +1396,10 @@ static int elants_i2c_probe(struct i2c_client *client, init_completion(&ts->cmd_done); ts->client = client; - ts->chip_id = (enum elants_chip_id)id->driver_data; + if (id) + ts->chip_id = (enum elants_chip_id)id->driver_data; + else + ts->chip_id = EKTH3500; i2c_set_clientdata(client, ts); ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");