From patchwork Tue Aug 7 14:06:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10558749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03C08139A for ; Tue, 7 Aug 2018 14:10:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E62512A1A0 for ; Tue, 7 Aug 2018 14:10:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3EE52A177; Tue, 7 Aug 2018 14:10:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B29EF2A1AA for ; Tue, 7 Aug 2018 14:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388569AbeHGQZJ (ORCPT ); Tue, 7 Aug 2018 12:25:09 -0400 Received: from mail-sn1nam02on0071.outbound.protection.outlook.com ([104.47.36.71]:8464 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732510AbeHGQZJ (ORCPT ); Tue, 7 Aug 2018 12:25:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t2C4ARvYO61abTF3NEybjqJdq85XxGEofIOsGCo7aW4=; b=vb+4hL7rQ937VRyg7+8vDZhdM47+MqsZvLUZHhOenrVIUH/xMqJxDPPQcbYOhnTrvUtFkoascq9Qvvr+9ULjpAM0UaGsiDCTjxZZckSY62ZagZBqf1MVA+MR+uOM0gmJnAOqd6/J+NyH/ILqZZfuC8sHAMzAPItpWGAjtX8tcP4= Received: from DM5PR03CA0046.namprd03.prod.outlook.com (2603:10b6:4:3b::35) by DM2PR03MB557.namprd03.prod.outlook.com (2a01:111:e400:241b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.18; Tue, 7 Aug 2018 14:06:45 +0000 Received: from BN1AFFO11FD027.protection.gbl (2a01:111:f400:7c10::196) by DM5PR03CA0046.outlook.office365.com (2603:10b6:4:3b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1038.19 via Frontend Transport; Tue, 7 Aug 2018 14:06:44 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BN1AFFO11FD027.mail.protection.outlook.com (10.58.52.87) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1017.15 via Frontend Transport; Tue, 7 Aug 2018 14:06:44 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id w77E6i43011885 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 7 Aug 2018 07:06:44 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.301.0; Tue, 7 Aug 2018 10:06:43 -0400 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w77E6fs9031406; Tue, 7 Aug 2018 10:06:41 -0400 From: Alexandru Ardelean To: , , , CC: , Alexandru Ardelean Subject: [PATCH] iio: adxl345: move null check for i2c id at start of probe Date: Tue, 7 Aug 2018 17:06:05 +0300 Message-ID: <20180807140605.19156-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(39860400002)(396003)(346002)(136003)(2980300002)(438002)(189003)(199004)(486006)(126002)(2616005)(8676002)(36756003)(305945005)(478600001)(7636002)(50466002)(476003)(356003)(246002)(2201001)(6666003)(4326008)(1076002)(2906002)(107886003)(14444005)(44832011)(316002)(39060400002)(106002)(16586007)(110136005)(336012)(54906003)(426003)(86362001)(575784001)(8936002)(47776003)(53416004)(186003)(51416003)(26005)(7696005)(48376002)(77096007)(5660300001)(1857600001)(50226002)(106466001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR03MB557;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD027;1:rpVxOrIY24fI0E/qSP7U9QI1I2aaODSwFZTablE/YZN2SVpx/ZOVHLMxR8daGp34kJy+TvZmha5KmR7y7e5ti2biZAPZGK2khjTDbpMLLA8wRGBzFPkOvSSwvaqSt5DB X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3253b792-b2b0-45d3-e184-08d5fc6f0228 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:DM2PR03MB557; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB557;3:D2iiQrADC7XotdB89y4IYIJolR5EE2d40AyvTXKontRKBRyiJooQ/bhHL5Up7DyrTSkViA/Pv/2Zs0aAprfk85YqAUlScEnlCFtX5SY4z3MHujvXc10VrFQ4noNs0T4t6EQX/oZhYSvfcFaFU0eOidgU+x8QBqukiDkTsOcbtfkklboPnyBN6D8E065lJrhJXuI7kgjm+uozygvMEhblk2W+O0yrcBANan3ESLuGeo/HNyPCeeGdO6Q0MyV2LbCkas2TJRXxJJuwgni4x+UZlpUp7QPm0zduns7K0zshQCq/P1dwDajeC5TMryf+Cl/Grec28B1aOrS79xzgHXyUmCxzBgP4ML00ROFFbcE8MN0=;25:sJqtrOx1/PTJqTOuKkC5eI9VvKokT/L6gnyd05Utopn6TvqckrbBWmojd+GZ/VVfm4ED9tsxKBzeSbNyvK1V5AATPCL/Kn+p2nn091Am+P34AdxpvDRImI6ki6wkwUHdDS9/k5Gh+P0i7rt/4yMDVUoCN/UTVi5EkkxHhGt1dBSJu7Jk7GStRnKbBl7hkwZapIWzTGsdoGHfxV5Yd6PLxObnMNFaz97mrazcedx3k3BLabjDj29euvyoCO2fdW060FCEGt8CTitDwR/5tk9EKwjOtg4A969iHnmazQwVcAHH581G5ZgWNYp3xbVnr8dyFa58U9CUf4Qyu3feBl4/TQ== X-MS-TrafficTypeDiagnostic: DM2PR03MB557: X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB557;31:h8z1WCAkEgheDGFq2xrt9MjbrKKtSOaNeTy6YSxvA8+pCRAA+qteJGwOj4MlnD8DSgP99Kod9HKq9SaEUgK92gQeBgFktvgJ9szBYmPOBfrcz+NOroUyHut+tD7cCgziBrOE8HHZY0ZanyfxU1PWR2808TnpmKPkMGgjQTPOe7Tvj3+YUxsE9PGLLjafcrmyejVDq1z5VIhbNVXRI5/QROR6Q3HO/4w0MxYQpDLGG7k=;20:HcVZklnDvnTvmejFLM10jNVbrzvnXYFDZ+Z3Dg/SggBCncE7yklNdEdxoqQmAnScgEGygLy+Pei/RwPhBazLW51ZQMn5V5MBpynm1O7K0+yrmYp3v+k4B27mYISWExwcXRgvCD6k42/LpOzz5IGSt1921vEZwYnerHl9rczOwJBxZphHBccwXfMizj5Ve6b/jECV252ZEVoQRPymrFvuoAKSyR8bgBv1dRitLh0YsEjeEGnqlp3HHKt0SFMPD+89rXxu7AmkpppjEL58ecE1Z16BDijdx70VNmqsMtyHCdaK4CJp3NbcTOuhD7EQWS4pRxCN/CpwvtlLPVERfbQtYjq0oQAheZYvuYL9553soKLRl+XBjMxRmnau1hjCxXN5bua55VOH9UcOer3qBfXj55ZH4HeKu1hEd8M3IZ3QD94/Iwro/WV76stznT1BIKGyFrycWTaQWpURFt72fVDkX+a8W7qN9ZD+/4mKq622hu3uO0kPXLRSEXEEihHXykrS X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93004095)(10201501046)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:DM2PR03MB557;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB557; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB557;4:tLgoYeIHP9UnS4Q6z/GeYz2IiJoyKoMsEfAug1oz5nyA9rTWX+EPCqaNd+M2jv/JJas0ylY83qvBJSQD/sPN1RpR++fB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vyDBqoIjatBaGCdWe01CkGDvKtQbng21z/w7mT0aSpx6M6BcJr9YVhOwPBnFIIICJ/rzTip0rXDD9PdwCT4nT6esmxOLdCgHczgMFZ/p8TPLpJfUkgSsU2QLDF0kPAA5MtfIkWIjqd/p/4zIG2ijNqElUxG+5SNQ1tgLjhl2FHzmmzAIZhUmZg8oonw9VVXRJUGnDlHPyQyNNXur60sGvxhLmz/Oekeuel+kAdrUHEWS1lu+UknQ==;5:XhyppLbMKsjE7z8APekcoO30h1i8DI0b8/npEmYfd8OZeigtr7WOC3tLNw9AiDuAjtUxe+DAc33E0Cn+x+C39VDJAjVh6+IzoJirCoYlJ8i/cV6MOhHSiRVMxyoUJFt2FeLmoG0vsSmdUjQPSr4JDQhr/gwiMUgOGgMhWFE0nx0=;7:7eCBPAxsM1e2BuZ9QxHB0x/PrnCBwKULhaFKHcDNVwYjY9mmI/498sg5WsJVQWuHtVU3El6SxebTmu/6EN6e2/uW0mVQYPUU3z1RkS6sUZ0ULGFTeE1jNaw4kPNwg/xV2N2a/GHbB0RbZBIQcz211EPxoSxIq8jKohc1reCc0m/3kq0mSweJPPU0xN81INA6EAQ7mq409Rk4687bk7olO7r/rFp3CWxhrDngymiMwS1MpuuUyQ/NL6fe8L2soOkv SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2018 14:06:44.9502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3253b792-b2b0-45d3-e184-08d5fc6f0228 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB557 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fixes ef89f4b96a2 ("iio: adxl345: Add support for the ADXL375"). This was found via static checker. After looking into the code a bit, it's unlikely that there will be a NULL dereference if the `id` object in that specific code path. However, it's safe to add a NULL (paranoid) check just to make sure and remove any uncertainties. Reported-by: Dan Carpenter Signed-off-by: Alexandru Ardelean --- drivers/iio/accel/adxl345_i2c.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c index 785c89de91e7..f22f71315a0c 100644 --- a/drivers/iio/accel/adxl345_i2c.c +++ b/drivers/iio/accel/adxl345_i2c.c @@ -27,6 +27,9 @@ static int adxl345_i2c_probe(struct i2c_client *client, { struct regmap *regmap; + if (!id) + return -ENODEV; + regmap = devm_regmap_init_i2c(client, &adxl345_i2c_regmap_config); if (IS_ERR(regmap)) { dev_err(&client->dev, "Error initializing i2c regmap: %ld\n", @@ -35,7 +38,7 @@ static int adxl345_i2c_probe(struct i2c_client *client, } return adxl345_core_probe(&client->dev, regmap, id->driver_data, - id ? id->name : NULL); + id->name); } static int adxl345_i2c_remove(struct i2c_client *client)