From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753392AbbL2NEg (ORCPT ); Tue, 29 Dec 2015 08:04:36 -0500 Received: from mout.web.de ([212.227.17.12]:55263 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753294AbbL2NEc (ORCPT ); Tue, 29 Dec 2015 08:04:32 -0500 Subject: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection References: <566ABCD9.1060404@users.sourceforge.net> Cc: kernel-janitors@vger.kernel.org, Julia Lawall To: LKML , Lee Jones From: SF Markus Elfring Message-ID: <568284D3.3060006@users.sourceforge.net> Date: Tue, 29 Dec 2015 14:04:19 +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:QiKu3yagUqA64Jy+I6LNj6SZsNnI59GzhqTG4ZKOKYIlKhbV0Ka TktptMhY2CbET81BssDb49l7OBvOl8n/LumPBOzrw/tKgbu2paGEim1K0E8if5ChtIazJ6T JXDQkHkERKVQonI6PKHysc5Wyy2IFCOcUM9l5B1gB9/kg9t2G7iQD8KBZeZjfBC67jRY+B5 cozljkE1IPAxED8SXdCRA== X-UI-Out-Filterresults: notjunk:1;V01:K0:H9GycUivLs8=:EtV/YDa+2So3wSXZwQ+tCS CKSvQc97rXA64ZDkXpW3Y8E9dd7xgetw+WYxqJcArkqrRg4awBWKBW2wBk+wsfYFR30fXmppU 0SpMSuJlFGjNlU93cbnfvIK1aNzGQRt++EISBgmON+xfFqSpJ3TitvnZelATFrQNe6+VhYq8d alN3U04rm1SQX5pw1I3Ruyt8lW7/X2r+dEckrza2ze+gGubqvIdI2wqnMYfYKcNxA48NxRyZr 5jJzMyzV3GZfJIYPSvRW0aYWUMdm6vwN/AEXgocxPelJjEHHqmhHoVz8G8kR0eegOC5tJHGEg FNUTMXEF4raTTXzvcY/uam/X2Hf4cuF32cY1sUhSTWsbGq5pVD2/3IVVGdQeHpbOLz98xaS4I 4t5KV9zuCbHi/nBUDB05MK5hVN6ZtOG5ZOT5EdF61qufCVASfNc7VHwne7KNdFoNrX7xLCwo8 oLT9lwnSOIeF1vJNZil18qAEZ0kYsQkiHpRNnLEVZmyEv4RMTFvL8mOZjNlJLlL3hSH/1lbS6 gNQbJ24sbfGtUsrFRTUHGYAQNaoixVzIpOaaWrOH+IIy+FoK2PKF13ATU8LpHLogncXpK9XDb SaIQXn3cMHhAvQgJZ6VJcXL+V8EbQrchXGTs6upgx3yKU6O11wn+nfKqR1/fq8fmf5daY6mPA X+fPwcwtZyEYrCctFcABuLziO/nUeY3j9zHk7i9BNYb8KP+KOrQxDoNRY6cFI+7+Rve0PNH8G TVG5tuLzL8l1+OQwkTDAB47OMVawNmQDdU3OASSoHn3m55B4dWi46v47vWX7ejNrY/Rd/EviD 9eC3/AflcmOSdeGLOXVC/KN+1eivg== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Tue, 29 Dec 2015 13:56:42 +0100 The platform_device_put() function was called in one case by the add_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/dm355evm_msp.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index bc90efe..e4aa1b8 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c @@ -202,7 +202,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, if (!pdev) { dev_dbg(&client->dev, "can't alloc dev\n"); status = -ENOMEM; - goto err; + goto report_failure; } device_init_wakeup(&pdev->dev, can_wakeup); @@ -212,7 +212,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, 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; } } @@ -225,19 +225,18 @@ static struct device *add_child(struct i2c_client *client, const char *name, status = platform_device_add_resources(pdev, &r, 1); if (status < 0) { dev_dbg(&pdev->dev, "can't add irq\n"); - goto err; + goto put_device; } } status = platform_device_add(pdev); - -err: - if (status < 0) { - platform_device_put(pdev); - dev_err(&client->dev, "can't add %s dev\n", name); - return ERR_PTR(status); - } - return &pdev->dev; + if (!status) + return &pdev->dev; +put_device: + platform_device_put(pdev); +report_failure: + dev_err(&client->dev, "can't add %s dev\n", name); + return ERR_PTR(status); } static int add_children(struct i2c_client *client) -- 2.6.3 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Tue, 29 Dec 2015 13:04:19 +0000 Subject: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection Message-Id: <568284D3.3060006@users.sourceforge.net> List-Id: References: <566ABCD9.1060404@users.sourceforge.net> In-Reply-To: <566ABCD9.1060404@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: LKML , Lee Jones Cc: kernel-janitors@vger.kernel.org, Julia Lawall From: Markus Elfring Date: Tue, 29 Dec 2015 13:56:42 +0100 The platform_device_put() function was called in one case by the add_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/dm355evm_msp.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index bc90efe..e4aa1b8 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c @@ -202,7 +202,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, if (!pdev) { dev_dbg(&client->dev, "can't alloc dev\n"); status = -ENOMEM; - goto err; + goto report_failure; } device_init_wakeup(&pdev->dev, can_wakeup); @@ -212,7 +212,7 @@ static struct device *add_child(struct i2c_client *client, const char *name, 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; } } @@ -225,19 +225,18 @@ static struct device *add_child(struct i2c_client *client, const char *name, status = platform_device_add_resources(pdev, &r, 1); if (status < 0) { dev_dbg(&pdev->dev, "can't add irq\n"); - goto err; + goto put_device; } } status = platform_device_add(pdev); - -err: - if (status < 0) { - platform_device_put(pdev); - dev_err(&client->dev, "can't add %s dev\n", name); - return ERR_PTR(status); - } - return &pdev->dev; + if (!status) + return &pdev->dev; +put_device: + platform_device_put(pdev); +report_failure: + dev_err(&client->dev, "can't add %s dev\n", name); + return ERR_PTR(status); } static int add_children(struct i2c_client *client) -- 2.6.3