From patchwork Sun Apr 17 21:41:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 563231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F2FCC433F5 for ; Sun, 17 Apr 2022 21:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235095AbiDQVpS (ORCPT ); Sun, 17 Apr 2022 17:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232635AbiDQVpR (ORCPT ); Sun, 17 Apr 2022 17:45:17 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EAD9AE6B for ; Sun, 17 Apr 2022 14:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jY+WMr/q3uyEIC0jOIkaIfAoA13tJlG/8DzdOFgjvHoefJWHpjs170AA+zI9zOX5G3MSN6XGofwKba/NHWhN4dkrcVdsvpotkPNCkA1UkcIR2qRudeQMO0qievNC7sMN4y0VNvzohzbNYGvw1Wh2so/5c0z1xdByiiRWuTS7KrwlK1+NJEEleY2yrPF8qYSdODjf8FYf7t8alGquo4CgCqNrdLOQhWaWkYFP0kfSFQkQ9VmKFCvpvHcEYiCS1ky4732bicbMFm5BiC8EG1Zn08SfhfibR1e3cUyrt1H3u+rXzBDbSEyahtTWOG5efc11uqIV3bwvrF/2Nu9AR0I62g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iJLs4I2gL5SmmHw1lr3BjQS24AFq2cz0/zMkglAy/JU=; b=AZpyGXYuh3ePP9pUonPoDik0BsFgOVsnoDWsW2uMqgq6gkIM7hFjBgQpigBytP2KfVTZLH9oClKaZnium+5v7WQ03IrN3sxuw3ePFEO0hFGgXRzwXghpL4QVv7UlzY063lnCSkoKYDTudAGwYrz4+InPAMJmym7l3bLFaHTbtUkwTA7IuCPmWfAECOpS4Y3jprN9f7l9quhl7U+1srqM+CDZkfJOdRZ+hf+x/HF5XHtFRqF+T1XGJIViNIEk2Tx2ndMCia6gqkd1ZKdz4U0OrA+RSZV5lUsLEyi0M+oerEiTItJ8C14eBgxmqg66dZfFzVf5rqBkzd6YnuwfZw8EYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iJLs4I2gL5SmmHw1lr3BjQS24AFq2cz0/zMkglAy/JU=; b=N1ljqH8p7lTLtWikCCebvksexcsW0fk7EY47TSHUVOxVY3e29eSWBEmrOuPJLAvWKpwA0BycTqPPBWtj12wqNqfvst6vIhH5ZMI3VrNdapBOQDwCGukpUzoDBE+qSddgK/YHdx5jjkDDtPw38o+jUnsXCWIbcz70SS9Wg69tSg8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=labundy.com; Received: from SJ0PR08MB6544.namprd08.prod.outlook.com (2603:10b6:a03:2d3::16) by BYAPR08MB5749.namprd08.prod.outlook.com (2603:10b6:a03:120::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Sun, 17 Apr 2022 21:42:35 +0000 Received: from SJ0PR08MB6544.namprd08.prod.outlook.com ([fe80::700f:b135:8bfa:4408]) by SJ0PR08MB6544.namprd08.prod.outlook.com ([fe80::700f:b135:8bfa:4408%5]) with mapi id 15.20.5164.025; Sun, 17 Apr 2022 21:42:35 +0000 From: Jeff LaBundy To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, Jeff LaBundy , Dan Carpenter Subject: [PATCH] Input: iqs7222 - avoid dereferencing a NULL pointer Date: Sun, 17 Apr 2022 16:41:32 -0500 Message-Id: <20220417214132.497487-1-jeff@labundy.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: DM6PR05CA0059.namprd05.prod.outlook.com (2603:10b6:5:335::28) To SJ0PR08MB6544.namprd08.prod.outlook.com (2603:10b6:a03:2d3::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d55341d4-86ec-4277-5a17-08da20bb2f5b X-MS-TrafficTypeDiagnostic: BYAPR08MB5749:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vazKLcDwNcPdLg5iJYJcDurwcHFDlSbcGD47PomxWTaxF3XBZ13/1lC8T3z40bTLG05eh6vdk/PkjvRlD87qtSXTOhEDCixW4iO+wRZODKDGc0beCpCqTxb8c4P9F7mV0CexDevG1U2mD5MzbtPVggNGJm7f7HsRiORXgijQ4fSB6KH32r9TnNKR7DxRXkSEO6SJbOBvMgT7658zeoVKfdBX9uOpHVvsj4qIn54zepV1e/fcINVaVw4q8PMS6D3VfK3TY51znl4IbheyqoduWfxmev+ThMWkvnkdQUCVRnjExQ5R1BYKTE0NEJGq9RklMf6UMB0+j2Hj6Cis63n/dTPTgBA1k4465eaYtKO5jaxcNRRstlAp7k6MVtZWvb6VZ20K9GdEiIRmj4X6kpPCv/NjqRKuAvcWBaMHMRB9RL8KkIrj8J6IQeoNERErInqQ7vZt2AHnAOYdaGXgqPm2NdVYCeEgOGWX9mMS3q/0NkbZnsWHMVdHhAfZC1q553W2mSVxZUT1C3FPhfZv4KdmIrXDql67xBH7dpd90yqGu5M4eGXOVI+9qTIFxYJdAPetUN6vOBlODmkbViiTUGkiteAMu5zeY4eUwNaaoqmKa9xbE7gv/MnDN4b3rqsmwqJwpMsYD8qc8fwIlnWTnKKYX1EqWoRsWsJXcTUOq9HmrCQ5l9Y1zz06Dn6QLCwIUE00q+tXzDo9PqI7/LSD3mtyBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR08MB6544.namprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(376002)(366004)(136003)(39830400003)(396003)(346002)(8936002)(6486002)(38100700002)(6916009)(1076003)(66946007)(66556008)(66476007)(4326008)(2616005)(8676002)(26005)(186003)(54906003)(38350700002)(508600001)(6512007)(2906002)(52116002)(83380400001)(6506007)(36756003)(316002)(86362001)(5660300002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ekuaK2prxVv8/1AnpM5ejpG+IVcZ4EiqRRsFghGjPzvoqdQCnSbWncHUs4OeAL3bUZbUWjgbpnt6RCn+Mwj9e841l/ux5X7OgDxd1lO3NEY2HpeJFfw4t3FNUrfKBEsTX7zeA0oSAbptxmjzzLMX6cDculiDAFq0fvyhDtRvzHwtho6e+4dMRlf/zOw6VLh11CnYqYcbpjGKqI6MqXfaZkE+vixKxKkDjXPitKTCdGuflHEnT3wVhvy+9Rci94j4qMPaGDlE1CX955Y6dGLlopEGVAjna9m6Nc5c5a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zWt+FMPcUUIlDVRy9dFe3loPCUoxzPK22EBo5xND4A+OAfwbulLs8nxPSJufJ+7dbs8TmAh9bXjoUHJ+RWsI4tLC47ViFJEPL5tMLP5n5U9K872Jczzr6TazKoCxz44EHCeMxLfS+HgoXqgxYqVgClALh3dbt+gfsCGoelfRgvmnbYVYrHVp0nTiXO323Od1y3geFj6QHu1tC2iIsmGKcGDdqAEUoGSl/cjuwFh8fmXKR4dCwy6KikJ5iAaAYvnxzYLmUADPvoUFYNuIw5vJYanCTYvu2GwlsJ1kPKT03MarsvVy37+BTxsZ8myV6KsXzXV+ngHhXiRXcWOAGj5pJu1+SWwICw0SKV2N09tdFRJ3KewjEB2ENVQ== X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: d55341d4-86ec-4277-5a17-08da20bb2f5b X-MS-Exchange-CrossTenant-AuthSource: SJ0PR08MB6544.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2022 21:42:35.3709 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D93VwFzrkSRQAjRT5ZXgiN4HIAy7Wz4bpscv+dPy8/LwUerVSEjDxs0piq5nVTJV6SZJQ12temntFBJRmrS0Fg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR08MB5749 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Select callers of iqs7222_parse_props() do not expect a child node to be derived and returned via pointer. As such, these callers set **child_node to NULL. However, this pointer is dereferenced in all cases. To solve this problem, dereference the pointer only for cases that expect a child node in the first place. In these cases, the caller provides a valid pointer. Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C") Reported-by: Dan Carpenter Signed-off-by: Jeff LaBundy --- drivers/input/misc/iqs7222.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c index c0b273222092..6b4138771a3f 100644 --- a/drivers/input/misc/iqs7222.c +++ b/drivers/input/misc/iqs7222.c @@ -1534,8 +1534,8 @@ static int iqs7222_parse_props(struct iqs7222_private *iqs7222, enum iqs7222_reg_key_id reg_key) { u16 *setup = iqs7222_setup(iqs7222, reg_grp, child_index); - struct fwnode_handle *reg_grp_node = *child_node; struct i2c_client *client = iqs7222->client; + struct fwnode_handle *reg_grp_node; char reg_grp_name[16]; int i; @@ -1550,7 +1550,8 @@ static int iqs7222_parse_props(struct iqs7222_private *iqs7222, * for additional group-specific processing. In some cases, the * child node may have already been derived. */ - if (*child_node) + reg_grp_node = *child_node; + if (reg_grp_node) break; snprintf(reg_grp_name, sizeof(reg_grp_name), "%s-%d",