Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753765AbbL2SeZ (ORCPT ); Tue, 29 Dec 2015 13:34:25 -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 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@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:3LFbW6GNUlRqmop9ccWVj9Suo0tsWEh0deqa932En8jDJqmYLrr Bv3EkYi79qERSR7Ay5dfJmKWSt3RajCI0wPAN6PKg4lDqX3GGQCCAqMN6JqGs8Ojb3y6Sch SLjShg+otOuOrWAcmmVP1TV77k/AWfKLPsQHXPrKhQFr1YXtTsQsx1fNkQFPAwHZOUFa98O BDmXPQQIU6ag2iphu2Olg== X-UI-Out-Filterresults: notjunk:1;V01:K0:qRod9lkKiP8=:d1siNeYBMv1rnqQfm9oQV2 XQSfyk9FawNZ7Ckfh022UEJd2RcAPJejvbdghAULcdveZhkNK4KyNsUWfbd1wHn2Bg1vo/TGb Ff/iKV+urTI2IWi2O7Rt0BI9oalXMuWoRmY4jE+xO/l0GwiSea/aYBMHrXkcOqHft2NjMEwdb zFJFM8w8rGvHEdxsx/SIjiUQY6l6KMWzA0DJtRxJdCsD6qCoW7l00YrRvb1JCEtjNOsVniqOC RzdmM+dcPPc/GevUSwV1Vwdf9WwG6XczZPNnHB5+mo5SDzoFK5wrAH9bAf25VN0yHJNwKtVcV 6QU+AriUyGeLAXDWyXuMQcdo4Sceu8iN5OxmrOSQe43xuO3Ff+gCWQBH4PsDeXg3GPXT3M1iA Iks1ggSm8iR/oaRJOeqVJKWrjjkAwGCTosEkbKpxbgiZcokwPHUUWMkEVFV6u+ezGbVUQqsMH S/DAepZsmR0ud343zzI51MCjAQBLH6avKSX6to8RIl8aW5SP+4zdu06OGHjCh7BkMJZLJBRUH h4HkT2Z4W6k/1wC9rsCZ1bWI8OVIZ68RIVeHpiL4ERswFP9pYj+Huz41r+qvenDoS/EjbLH9e txThkthdOqvsvG1aX+oxMqTKSNU2+vu86tzoUpwm7CRZkc/guxXR5nR6J1HFgtvMxD172IzR2 HJkmJxP9F8hgq+p1SXOsM+2FX8GpZm8BjqgLWughnXVeU5FB72WCKq8/iu7lrBUufMoWlXwdS IQUdpQ/SQk5tqCAJFXXNhHmsFyiK6/BaCgPzFh7EtN8v5qTI83AOtg7aCivLHP8WZ6u/JXVI2 8GyPUkI+1zEMHsSCHdCIlzMlZ8HMQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2346 Lines: 77 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, -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/