From patchwork Tue Oct 6 21:49:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 7340221 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DB99D9F1B9 for ; Tue, 6 Oct 2015 21:50:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 012EF20394 for ; Tue, 6 Oct 2015 21:50:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8103202A1 for ; Tue, 6 Oct 2015 21:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753144AbbJFVuA (ORCPT ); Tue, 6 Oct 2015 17:50:00 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:33559 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753014AbbJFVt7 (ORCPT ); Tue, 6 Oct 2015 17:49:59 -0400 Received: by oixx17 with SMTP id x17so116650282oix.0; Tue, 06 Oct 2015 14:49:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=0qgZrcf62ELrtczTM/FFP5YRIG9hQ0xX1VHSOfii8Qs=; b=LdEMXuT6TO6rPAjHm+az3T7sqX02Ssu4QHaw9VmG9pYvZ+WhHbfHvyNnas5xUVffvz xqSdabhu8rAS98t/oQpyrkOxUM1+N93DOTidCj9vsU6ny8AOFTXmMpKyf+u657TqcwWG df7tI0lZVndWjLum7QY0T5c2vwjTVUc6iffaz/7+1I8OR1bLtmSpHSA265cCn5CXNtXD nuBJqreMqBImcFUhacz4P9AMwzl6uikhhcYG4E8DBNpbCj9GsrzleRPGAhhynqt7sYbg rAXnzQzqfiqwD8KmeGcb62o5nQ/P7cqnL524kcGo6Qd70WeYWu9Q5qjtKZC4SNtgb9JZ 2kwg== X-Received: by 10.202.198.139 with SMTP id w133mr21652300oif.72.1444168198639; Tue, 06 Oct 2015 14:49:58 -0700 (PDT) Received: from localhost.localdomain (pool-71-97-41-79.dllstx.fios.verizon.net. [71.97.41.79]) by smtp.gmail.com with ESMTPSA id d9sm15209462obf.19.2015.10.06.14.49.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Oct 2015 14:49:58 -0700 (PDT) From: fcooper@ti.com To: dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Cc: Franklin S Cooper Jr Subject: [PATCH] Input: edt-ft5x06 - Only call desc_to_gpio for valid gpios Date: Tue, 6 Oct 2015 16:49:47 -0500 Message-Id: <1444168187-3542-1-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.6.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Franklin S Cooper Jr Since reset and wake pin are optional the gpio structure for those pins may be null. Therefore, they can't be blindly passed to desc_to_gpio. Only use desc_to_gpio for valid gpios. This issue was detected by Smatch http://permalink.gmane.org/gmane.linux.kernel.input/45927 Signed-off-by: Franklin S Cooper Jr --- This patch is based on top of the following patchset which already is already in linux-next: https://patchwork.kernel.org/patch/7166931/ drivers/input/touchscreen/edt-ft5x06.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 7239c31..f877404 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -876,11 +876,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, struct edt_ft5x06_ts_data *tsdata; struct input_dev *input; unsigned long irq_flags; - int error; + int error, reset_pin, wake_pin; char fw_version[EDT_NAME_LEN]; dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n"); + reset_pin = wake_pin = -1; + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); if (!tsdata) { dev_err(&client->dev, "failed to allocate driver data.\n"); @@ -908,12 +910,14 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, if (tsdata->wake_gpio) { usleep_range(5000, 6000); gpiod_set_value_cansleep(tsdata->wake_gpio, 1); + wake_pin = desc_to_gpio(tsdata->wake_gpio); } if (tsdata->reset_gpio) { usleep_range(5000, 6000); gpiod_set_value_cansleep(tsdata->reset_gpio, 0); msleep(300); + reset_pin = desc_to_gpio(tsdata->reset_gpio); } input = devm_input_allocate_device(&client->dev); @@ -987,8 +991,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, dev_dbg(&client->dev, "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n", - client->irq, desc_to_gpio(tsdata->wake_gpio), - desc_to_gpio(tsdata->reset_gpio)); + client->irq, wake_pin, reset_pin); return 0;