From patchwork Wed Jul 8 20:30:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 6751141 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 78C0CC05AC for ; Wed, 8 Jul 2015 20:31:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D43D20552 for ; Wed, 8 Jul 2015 20:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A01702052F for ; Wed, 8 Jul 2015 20:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758783AbbGHUaw (ORCPT ); Wed, 8 Jul 2015 16:30:52 -0400 Received: from mout.web.de ([212.227.15.3]:52597 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755529AbbGHUau (ORCPT ); Wed, 8 Jul 2015 16:30:50 -0400 Received: from [192.168.1.2] ([77.181.59.179]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0MPp0k-1Z96V23gAM-0051iD; Wed, 08 Jul 2015 22:30:46 +0200 Subject: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put" References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> To: Jiri Kosina , linux-input@vger.kernel.org Cc: Linux Kernel Mailing List , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <559D8874.7090407@users.sourceforge.net> Date: Wed, 8 Jul 2015 22:30:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <5317A59D.4@users.sourceforge.net> X-Provags-ID: V03:K0:6iIRynyAWS4gbv0P/lRNBN70myJ7NrGH5U4gQMxjlOOCCDH6Lii 0U2Yh3grZ+Sc58DO51xYUgxyhDWIeQtlwkLxQih+Kbldaz9jIUdbwoY7ab4VxGcJ8rv1Em8 TBDa9rNbdrfD78ws+u8ofWzr5v29PGAKmK2ATf5VLo6fguAf8mlMWWksGkfh9+WqkbMdc0x Lz2Nlj57zR7A5BwS2TkOw== X-UI-Out-Filterresults: notjunk:1; V01:K0:kLsdfHUnEfA=:mTXtI57QZShGzrDbBWCCFF bqwpyGgF3LCTNI9gd897dLcQaBx0Y4DgueTep3GA0wcahBxlylALbDX7BFttKTJz7BLTUOZkO cqlmGTATLPwVOFzERBwPjX+pQlyj/QpnchPh7RrVPXTet78UZlTs08vEbd+wzPaDBsNR4muaz QQomr/V9VW9QmcEVhHegsiudJqV8HQx4g4bEzqLPBeQ4iMm8hNoH4qhcaqdiE8hqC1pilkgIm u15+fey9lft0p9lyvUFjTVlFvp8kNf6h3VAEX1O7D2IwrmljyfTA7E7ds+wAxMFKvqTBwVAYg vdi4xr8YeSOGEgYlyEGhazvzUXXm2cU6LNkBGsitfxh/p3TOPcm7m+8GJCRO04fBxOVVV4V01 MlEwBynpZTrkmEW52xnJmkNYJld2NagMhwYw6cfY9sufXBY/OOMNpHb+oevNq4UIhcie+bwE9 OQjvDArEjV7eXAJZZY5eFFmwjVktqqwaGu8QxaVppCJ5IKaUnEoxp+Gg06KvtXSTWNOclA1MS InSBq42ePsMJLuYEkQFfNTpbw/0swLX9vXFMiT6V1kj7pK+PA03w6FQShHvcVS2QTUKU5dGd5 Kdfc1iWRd3hVIicrXDCYrJJ5i5TYPTUnhBlTSIxI7q15dM1ipFN871y8FJtwpSRSObE6uDrdd 1co9095e2q15dIHIND6aeiw3boc5A6tqjXGmi7hbnB6ghFK2tPV0UYy+OkVtnarayEik= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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: Markus Elfring Date: Wed, 8 Jul 2015 22:12:25 +0200 The gpiod_put() function performs also input parameter validation by forwarding its single input pointer to the gpiod_free() function. Thus the test around the calls is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/hid/i2c-hid/i2c-hid.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index f77469d..09ff4e7 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -1048,9 +1048,7 @@ err_pm: pm_runtime_disable(&client->dev); err: - if (ihid->desc) - gpiod_put(ihid->desc); - + gpiod_put(ihid->desc); i2c_hid_free_buffers(ihid); kfree(ihid); return ret; @@ -1074,9 +1072,7 @@ static int i2c_hid_remove(struct i2c_client *client) if (ihid->bufsize) i2c_hid_free_buffers(ihid); - if (ihid->desc) - gpiod_put(ihid->desc); - + gpiod_put(ihid->desc); kfree(ihid); acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));