From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758850AbcAKIbN (ORCPT ); Mon, 11 Jan 2016 03:31:13 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:36491 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758065AbcAKIbM (ORCPT ); Mon, 11 Jan 2016 03:31:12 -0500 Date: Mon, 11 Jan 2016 08:31:08 +0000 From: Lee Jones To: SF Markus Elfring Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: Re: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection Message-ID: <20160111083108.GC14104@x1> References: <566ABCD9.1060404@users.sourceforge.net> <568284D3.3060006@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <568284D3.3060006@users.sourceforge.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 29 Dec 2015, SF Markus Elfring wrote: > 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(-) Same comments as before. > 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) -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Jones Date: Mon, 11 Jan 2016 08:31:08 +0000 Subject: Re: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection Message-Id: <20160111083108.GC14104@x1> List-Id: References: <566ABCD9.1060404@users.sourceforge.net> <568284D3.3060006@users.sourceforge.net> In-Reply-To: <568284D3.3060006@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: SF Markus Elfring Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall On Tue, 29 Dec 2015, SF Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 29 Dec 2015 13:56:42 +0100 >=20 > 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. >=20 > Implementation details could be improved by the adjustment of jump targets > according to the Linux coding style convention. >=20 > This issue was detected by using the Coccinelle software. >=20 > Signed-off-by: Markus Elfring > --- > drivers/mfd/dm355evm_msp.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) Same comments as before. > 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 *cl= ient, const char *name, > if (!pdev) { > dev_dbg(&client->dev, "can't alloc dev\n"); > status =3D -ENOMEM; > - goto err; > + goto report_failure; > } > =20 > device_init_wakeup(&pdev->dev, can_wakeup); > @@ -212,7 +212,7 @@ static struct device *add_child(struct i2c_client *cl= ient, const char *name, > status =3D 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; > } > } > =20 > @@ -225,19 +225,18 @@ static struct device *add_child(struct i2c_client *= client, const char *name, > status =3D platform_device_add_resources(pdev, &r, 1); > if (status < 0) { > dev_dbg(&pdev->dev, "can't add irq\n"); > - goto err; > + goto put_device; > } > } > =20 > status =3D 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); > } > =20 > static int add_children(struct i2c_client *client) --=20 Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org =E2=94=82 Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html