From patchwork Wed Jun 24 17:28:53 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: 6669671 Return-Path: X-Original-To: patchwork-linux-scsi@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 DDCC6C05AC for ; Wed, 24 Jun 2015 17:29:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 022A8205AA for ; Wed, 24 Jun 2015 17:29:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2426C20384 for ; Wed, 24 Jun 2015 17:29:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753846AbbFXR3E (ORCPT ); Wed, 24 Jun 2015 13:29:04 -0400 Received: from mout.web.de ([212.227.17.11]:58908 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753391AbbFXR3D (ORCPT ); Wed, 24 Jun 2015 13:29:03 -0400 Received: from [192.168.1.3] ([78.49.141.189]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MWjAd-1Za2qS17UZ-00Xvof; Wed, 24 Jun 2015 19:28:55 +0200 Message-ID: <558AE8D5.1020106@users.sourceforge.net> Date: Wed, 24 Jun 2015 19:28:53 +0200 From: SF Markus Elfring User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "James E. J. Bottomley" , linux-scsi@vger.kernel.org CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: [PATCH] SCSI: Delete unnecessary checks before the function call "put_device" 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> <546E2B02.5090902@users.sourceforge.net> In-Reply-To: <546E2B02.5090902@users.sourceforge.net> X-Provags-ID: V03:K0:UhSqNNCpMyvF7GyK3uxYTnLgoveAja4e10gGCHWhjErHt096yH4 Iz72xoOG1866eisYxrDUwXM49UHo/p7Ra4b65LpYErNzd4stPSnRfqP1Y/htquTgdyUSIcD TksocieRhpFhldk6Ahh6AW55cW86E4TFgCxHGcLRZMqosPfvXw8D5x7eB9U4pA23WWyXvTD xs5jdr0QvL3C13ZYS+WnA== X-UI-Out-Filterresults: notjunk:1; V01:K0:L9QueyA8GFA=:nZsYsf+wL1MZCX39a7vaGZ CfVXLdkYNsLfK1SrlymvSA9tZiJdp2yLMEbx64ll3hPElGomOIxx8Xn2SZHwBMah/tOIkHn7o Zl2WOlxvlqQRaHgNUsvf9K1X0zygktsqp1IgUtNmV5oD3A2T4MpGiirOZBOMt9RVC1cdlDrd3 wqCsR8ARbnAo36701X3waXLwAsUxHS1jAt3nl6yWb+HPVdad0qQDfuElC+HtT5UAWhtur9o38 CQtEInSVU8dBTOt8Lk/odxqkgL/D4LN/NNshIj4vXPtIpV0zejr8xAkbnNUEeyqF6G/4p9RHh VBRz4FH53s3Kepxq8lkjDyS8cUzGdhpkXCSqelsgVuy0cEAO+R8jRneRMz7oYj0GIHOoWwit6 rTUy0PBHejCQqKs3ximEVQKQ2mPf3eAWndrtcsVXqSbktVBXnXIldnzfGyqB5++c8G9IJFHf6 q1KX75OYSDmrsiobioYvnNgU9EDHpMUabe3EiB9q3/3CvNPMZTgnSWnTueY5YNdQaaKJ6L077 Y6sE8DLPf7EzkHlWRChuEotlkhIQGaILu/SBue4CqSWg6tdpg+tkpNZUJo7FJhOmIUrnML6/j eqJm3NpUgr7bWnnUju7I9QW4pEGF5mw0wnMJM+3plU5YLv26/HHN70bLm4oNcDVg0zFO3mbr/ 9xDM0JfacJx3vbEucgeSCkxtYhWc0vYxtsiWIcyt8snT4M7RQMFeQ6WzosqEvYnwkLTg= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-8.3 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, 24 Jun 2015 19:24:01 +0200 The put_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/scsi/hosts.c | 4 +--- drivers/scsi/scsi_sysfs.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 8bb173e..84c8565 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -336,9 +336,7 @@ static void scsi_host_dev_release(struct device *dev) } kfree(shost->shost_data); - - if (parent) - put_device(parent); + put_device(parent); kfree(shost); } diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 1ac38e7..9ed5391 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -425,9 +425,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) kfree(sdev->vpd_pg80); kfree(sdev->inquiry); kfree(sdev); - - if (parent) - put_device(parent); + put_device(parent); } static void scsi_device_dev_release(struct device *dev)