Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11920202ybi; Fri, 26 Jul 2019 01:50:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl9Fni79tnmlDEeffC+Xapc1N6SMjoIjMa0/CFV8ZSO6DjYfVSCNDqnFmnoRgBvLbv6JlR X-Received: by 2002:a65:49cc:: with SMTP id t12mr84462908pgs.83.1564131033444; Fri, 26 Jul 2019 01:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564131033; cv=none; d=google.com; s=arc-20160816; b=lESXiipWBw1eX/QO26U5rG0CndVma7qLfLif78ijdlq4eW1jnxxqZccu5BgsLEoZtj mtN2tSuEYjTIS7vcYsALaYkpWGV8oUzFBO9EA7Np+9QOXwpz1b2Ie8NPAfo2ECz9Jfl/ 3VjBu9ihR/vT0KV3IVOgVMosphbhuWBaRds8xd5u0SNW4c/kFp2rZE+PRHOohCNg7fbm xfKSkL+FVpgZo4Mo3KCrEiGSTrWy/4jWVbD8TwWB9OSePzGY3eD6UsefTTnrJH7JmSwy 6CUQfDutN46O4XAkLTVFhek7btKQ7pqEbnd2jvG7vYpMypNQLfeQ5NpM0B5Ob2M2hjff 7/Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=n+PSUAMKZPff5zesM1XSMM7/Tungo32ENdBEjQ0MAgI=; b=n5CYhCbXVrjBW0JwP6Bngwt/Uk0vbxvNINILeftRuEno38cVCxEOkgDyiKjHO3BBIP kyf2VxpohT2mpLXtlQZrN6Xb9QDIZaKBppEVl3tqX0psbx8LUKrngYeIACGjQfNjWeyH o9jqc4PiOizsa8Hi/HKtrtxlsbixvPNAah/2C4laKTMuVaVp31jpptDDF1li04SL6zyw BZV+kAD1Dhi9PluIezO4DDbr/4W9gm+KN6WVqCecNfUGNjpLlQt16v+2SijSAodF2rzq REmCUjKwUII/ws+Xxq3ZYq7go0qY9sriJ+KJ4X7ESb0iQJPccOI6lzWbeg+MxTMVAPIR cCyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R+u+xDer; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s38si20269362pgl.138.2019.07.26.01.50.18; Fri, 26 Jul 2019 01:50:33 -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=@gmail.com header.s=20161025 header.b=R+u+xDer; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbfGZItQ (ORCPT + 99 others); Fri, 26 Jul 2019 04:49:16 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41665 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbfGZItQ (ORCPT ); Fri, 26 Jul 2019 04:49:16 -0400 Received: by mail-pf1-f196.google.com with SMTP id m30so24191545pff.8; Fri, 26 Jul 2019 01:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=n+PSUAMKZPff5zesM1XSMM7/Tungo32ENdBEjQ0MAgI=; b=R+u+xDerujiwy7aIwIbcVjK9CQ1elm4f3hHj5YUsgz5N3B/svM8It4NRk7qF59knjA Djl0h57yc3oCQLkelcEamnbnJEeiclJ3Xlps59V8c3QC7pDVAR72uqPKvZVRhr9spg6n 7+/iPOZDqpr1WN4s27NQh6bb2bn/FiX/mjlW5iNmv8j3j3xYVnmDCtKRzNby+E7+PsU9 fMoZJo2qlicsQWGJCdoFwEH8M/XOoOs/zE/vsKajnli7hgUSiohsOeGk9FgedQeJisYy PEf12Gk7ux+Q1KLjgmOFoqVb3VMCDL7ezITkLW9NnA/T3hr5ilXvk0Hf+IzpSYMhaJaN 45lQ== 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; bh=n+PSUAMKZPff5zesM1XSMM7/Tungo32ENdBEjQ0MAgI=; b=ER/csp6Od7TabvN+6zdobCVwBArDh/lwTtSWuqa77Lyqa1T7F7PiRsw3I2dy4+JkMN +opu6dwQ1ZCDuqsEqmXCyFauMIhfTvRRlnF9UXeHQYmvrpU25OEDANhWp9vWzJcExyX3 gpIuk90BiRzCADlvFG2ac+nQd9hRCtLb7R01lqKgdgXIlCMscA4NVqJcXU+G2ZsiqnR/ 2GZJ55db/Xo55ixSpgY5/PmSicIX15jPEtSGgQHOpE6esQ/FpRlXi0sEDFueMXRpk1y5 dOVUfV6ug7ImPWLPGaySFpKRRoep1sTS72KfwClzjDSht3Me0kRzbhz8TL892ZUUuLT2 XcNQ== X-Gm-Message-State: APjAAAX2qXeIjsJTNPhfdG+TnO2ER7ndCqHrEwTrLz5Q01lFO/wSduWZ /EX5UEi567bRZ+B39xYFnQY= X-Received: by 2002:a63:b10f:: with SMTP id r15mr20757387pgf.230.1564130955937; Fri, 26 Jul 2019 01:49:15 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id 201sm62335492pfz.24.2019.07.26.01.49.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jul 2019 01:49:15 -0700 (PDT) From: Jia-Ju Bai To: dmitry.torokhov@gmail.com, gregkh@linuxfoundation.org, tglx@linutronix.de, allison@lohutok.net, rdunlap@infradead.org Cc: patches@opensource.cirrus.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] input: touchscreen: wm97xx-core: Fix possible null-pointer dereferences in wm97xx_ts_input_open() Date: Fri, 26 Jul 2019 16:48:16 +0800 Message-Id: <20190726084816.8487-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In wm97xx_ts_input_open(), there is an if statement on line 507 to check whether wm->mach_ops is NULL: if (wm->mach_ops && wm->mach_ops->acc_enabled) When wm->mach_ops is NULL, it is used on line 521: wm97xx_init_pen_irq(wm); BUG_ON(!wm->mach_ops->irq_enable); BUG_ON(!wm->mach_ops->irq_gpio); wm97xx_reg_write(..., reg & ~(wm->mach_ops->irq_gpio)) Thus, possible null-pointer dereferences may occur. To fix these bugs, wm->mach_ops is checked before calling wm97xx_init_pen_irq(). These bugs found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- drivers/input/touchscreen/wm97xx-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c index 0a174bd82915..f7bd0726a577 100644 --- a/drivers/input/touchscreen/wm97xx-core.c +++ b/drivers/input/touchscreen/wm97xx-core.c @@ -517,7 +517,7 @@ static int wm97xx_ts_input_open(struct input_dev *idev) wm->ts_reader_interval = wm->ts_reader_min_interval; wm->pen_is_down = 0; - if (wm->pen_irq) + if (wm->pen_irq && wm->mach_ops) wm97xx_init_pen_irq(wm); else dev_err(wm->dev, "No IRQ specified\n"); -- 2.17.0