From patchwork Tue Dec 29 18:34:16 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: 7930391 Return-Path: X-Original-To: patchwork-linux-omap@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 3CF53BEEE5 for ; Tue, 29 Dec 2015 18:37:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A503201DD for ; Tue, 29 Dec 2015 18:37:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80E532015A for ; Tue, 29 Dec 2015 18:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753587AbbL2SeY (ORCPT ); Tue, 29 Dec 2015 13:34:24 -0500 Received: from mout.web.de ([212.227.15.3]:59757 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753679AbbL2SeX (ORCPT ); Tue, 29 Dec 2015 13:34:23 -0500 Received: from [192.168.1.2] ([77.181.55.103]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0LrKEG-1a8KIx0PdM-0136N0; Tue, 29 Dec 2015 19:34:19 +0100 Subject: [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection References: <566ABCD9.1060404@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall To: linux-omap@vger.kernel.org, Lee Jones , Tony Lindgren From: SF Markus Elfring Message-ID: <5682D228.7070902@users.sourceforge.net> Date: Tue, 29 Dec 2015 19:34:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <566ABCD9.1060404@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CgPzFh7EtN8v5qTI83AOtg7aCivLHP8WZ6u/JXVI2 8GyPUkI+1zEMHsSCHdCIlzMlZ8HMQ== Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Tue, 29 Dec 2015 19:29:08 +0100 The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer. Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/mfd/twl-core.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 831696e..0d9350c 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -625,7 +625,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, if (!pdev) { dev_dbg(&twl->client->dev, "can't alloc dev\n"); status = -ENOMEM; - goto err; + goto report_failure; } pdev->dev.parent = &twl->client->dev; @@ -634,7 +634,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status = platform_device_add_data(pdev, pdata, pdata_len); if (status < 0) { dev_dbg(&pdev->dev, "can't add platform_data\n"); - goto err; + goto put_device; } } @@ -647,21 +647,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num, status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1); if (status < 0) { dev_dbg(&pdev->dev, "can't add irqs\n"); - goto err; + goto put_device; } } status = platform_device_add(pdev); - if (status == 0) + if (!status) { device_init_wakeup(&pdev->dev, can_wakeup); - -err: - if (status < 0) { - platform_device_put(pdev); - dev_err(&twl->client->dev, "can't add %s dev\n", name); - return ERR_PTR(status); + return &pdev->dev; } - return &pdev->dev; +put_device: + platform_device_put(pdev); +report_failure: + dev_err(&twl->client->dev, "can't add %s dev\n", name); + return ERR_PTR(status); } static inline struct device *add_child(unsigned mod_no, const char *name,