Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11945933ybi; Fri, 26 Jul 2019 02:15:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDAqernCBE7AAIJLAo4h3W5V2+j8IIny0axBnssOEHn5F1swFgyxPnGasvyP6KmxIPXJBk X-Received: by 2002:a63:7205:: with SMTP id n5mr35807161pgc.443.1564132533032; Fri, 26 Jul 2019 02:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564132533; cv=none; d=google.com; s=arc-20160816; b=pRsUXwhOb1HM/rPsivViQWxCmuBmbwMnpC7sH++UEDYpnj2DgM/0gMcATkzlVMkl6N 6F4L9NoCsDIuWpi7PJsEEcroj5jfQVKMc/LEeVLLyx5GTyyxWKsbt2avvOVqxsWMKCK0 RViErHD+ICkMcVR3HjKD3Lj8Rm39GMO+jNYapIXsHmWqDMWsLi9Osv/FEo2p0RzW5J// 13HIRnc/67ta1E25s1lKpYl9U1OgjOZheeVIUlGmuQ9UAoy5a73Cld633LEL44U6ZRV5 LJeouklcicixZzz3c0Rt3Uva3q/D+UAxnGX27SE3AcfWVyBvqZRTzjq4rad24Rcgky8I grEw== 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=TYiDJjF4yOS8bkmjhmB2OznvRayOVVC1oxEpAkjtmTY=; b=UQwZyfnFGMZ0p2Ezwy/XBAPCoBk4J6CYiltDSa3qeSMB6VPyqJhQZ2H/LWwPEAF19P KjRHsdQagdqfrM7tmi0DvE7VJNR6mfgcnBofSEOJP4pSln9Lx8xDKc1X5o54U3PUI0xX Qsvvs6/NOcJzuIP7BiSEjQSG1Gwxjh9bMwicr/LU6K4d5dbBIAdkL3TThTeHHDuDWutk yFLOzdkE09KGLZkXyPZwkoPL5gQ2tqVdjO9F0u2LzK9oxq0iZZLfQ51dJo938Ik+xTAq 0IerBheUfdsH5jyWI2oBqKmAuySQE2aPjsFcbHASJhZwlWl/DKbtE8Fe3UHMmNIW0eZb rwMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I61Gsocz; 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 h16si13584802pgl.318.2019.07.26.02.15.17; Fri, 26 Jul 2019 02:15: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=I61Gsocz; 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 S1726000AbfGZJOp (ORCPT + 99 others); Fri, 26 Jul 2019 05:14:45 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35537 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfGZJOo (ORCPT ); Fri, 26 Jul 2019 05:14:44 -0400 Received: by mail-pf1-f193.google.com with SMTP id u14so24235774pfn.2; Fri, 26 Jul 2019 02:14:44 -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=TYiDJjF4yOS8bkmjhmB2OznvRayOVVC1oxEpAkjtmTY=; b=I61GsoczxdHQtaJ6fHWGIB4x4LyJFbsdK7l2wJZBTM8JstVMhrNZuzZUEfXnocjdD7 yVW4nrN9xNDsJYYymIPOQ+1TgmY9cqEMM5hAM7Z0ZnxahB/dFGJJF/FgHKMY2EnmDuF6 81mqT7wx5lhXqI1xVYHgFcAWk7LWkuwy5fRbvWCIqGo1OvH6nyouRgROWhEciCu9dn3u 74Gku8Q9fbvNP2dSm5q2L/lflTNBXi8cUXfM5pNrtViUxxcX5B80TvJd7jIbdTi0HDCS Fl605ATEigDLBGWTTlGI9lyO1mjTgwt4mma/cMy75D3CMPKpyz6owXurOGVJFwi07FHk PJ3g== 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=TYiDJjF4yOS8bkmjhmB2OznvRayOVVC1oxEpAkjtmTY=; b=PjsdDRXs6Do+fL3fBaXJdeDmI5jjmNjtdfpPtg3zMJ/vJ4Wv90gtDcT6wtW0DrD+rQ 56V5MuTFjzWwaS2NBfJgT4Vh5TpqIiZ7E6ZEr0+tKwugoHUewy/pymnlpLrz+GMGT8wQ cDGViPJwd0QMYwxYOdjb2lI+WmBBmFLU5xGlCDS7npSgus60JV5ZHRfH4OJ/eB/ypQPO SwMwSb2yPloE/+Nh2eSjPMEeZZU9sq1byGo2TnGFK45xCr5iGVTG9JWvM+Vyx+25cYdp gyJebwfiUSGd8ngMQt34Wq8JwdPoDjCeq2WiCJwLg0Cs8gafDCYHev3pO2Yk+JA017be o1sg== X-Gm-Message-State: APjAAAVXjNvn/0pmVbrRtaM5WS9b+tqE1qaILmIKdrpkSv+n1GBbvQlz gPwNuAFJ0uE1ms6/RW/qcyc= X-Received: by 2002:a17:90a:1b4a:: with SMTP id q68mr96898848pjq.61.1564132484301; Fri, 26 Jul 2019 02:14:44 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id g11sm54686920pgu.11.2019.07.26.02.14.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jul 2019 02:14:43 -0700 (PDT) From: Jia-Ju Bai To: dmitry.torokhov@gmail.com, tglx@linutronix.de, gregkh@linuxfoundation.org, 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 v2] input: touchscreen: wm97xx-core: Fix possible null-pointer dereferences in wm97xx_ts_input_open() Date: Fri, 26 Jul 2019 17:14:36 +0800 Message-Id: <20190726091436.8866-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 at the beginning of wm97xx_init_pen_irq(). These bugs found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- v2: * Add a new check of wm->mach_ops in wm97xx_init_pen_irq(). Thank Charles for helpful advice. --- drivers/input/touchscreen/wm97xx-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c index 0a174bd82915..50b016abf492 100644 --- a/drivers/input/touchscreen/wm97xx-core.c +++ b/drivers/input/touchscreen/wm97xx-core.c @@ -374,6 +374,9 @@ static int wm97xx_init_pen_irq(struct wm97xx *wm) { u16 reg; + if (!wm->mach_ops) + return -EINVAL; + /* If an interrupt is supplied an IRQ enable operation must also be * provided. */ BUG_ON(!wm->mach_ops->irq_enable); -- 2.17.0