linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] swim: Release memory region after incorrect return/goto
@ 2013-06-04 14:44 Joe Perches
  2013-06-04 14:44 ` [PATCH 2/4] inkern: iio_device_put " Joe Perches
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Joe Perches @ 2013-06-04 14:44 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: linux-kernel

The code uses

	return foo;
	goto err_type;

when instead the form should have been

	ret = foo;
	goto err_type;

Here this causes a useful release_mem_region to be skipped.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/block/swim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 2f445b7..8ed6ccb 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -893,7 +893,7 @@ static int swim_probe(struct platform_device *dev)
 
 	swim_base = ioremap(res->start, resource_size(res));
 	if (!swim_base) {
-		return -ENOMEM;
+		ret = -ENOMEM;
 		goto out_release_io;
 	}
 
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] inkern: iio_device_put after incorrect return/goto
  2013-06-04 14:44 [PATCH 1/4] swim: Release memory region after incorrect return/goto Joe Perches
@ 2013-06-04 14:44 ` Joe Perches
  2013-06-04 17:28   ` Jonathan Cameron
  2013-06-04 14:44 ` [PATCH 3/4] mtd: onenand: samsung: Release memory " Joe Perches
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2013-06-04 14:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jonathan Cameron, linux-iio

The code uses

    return foo;
    goto err_type;

when instead the form should have been

    ret = foo;
    goto err_type;

Here this causes a useful iio_device_put to be skipped.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/iio/inkern.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 795d100..dca4eed 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -124,7 +124,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 	channel->indio_dev = indio_dev;
 	index = iiospec.args_count ? iiospec.args[0] : 0;
 	if (index >= indio_dev->num_channels) {
-		return -EINVAL;
+		err = -EINVAL;
 		goto err_put;
 	}
 	channel->channel = &indio_dev->channels[index];
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] mtd: onenand: samsung: Release memory after incorrect return/goto
  2013-06-04 14:44 [PATCH 1/4] swim: Release memory region after incorrect return/goto Joe Perches
  2013-06-04 14:44 ` [PATCH 2/4] inkern: iio_device_put " Joe Perches
@ 2013-06-04 14:44 ` Joe Perches
  2013-06-04 14:44 ` [PATCH 4/4] cw1200: hwio: Remove an unnecessary goto Joe Perches
  2013-06-04 18:25 ` [PATCH 1/4] swim: Release memory region after incorrect return/goto Laurent Vivier
  3 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2013-06-04 14:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kyungmin Park, David Woodhouse, linux-mtd

The code uses

    return foo;
    goto err_type;

when instead the form should have been

    ret = foo;
    goto err_type;

Here this causes a useful kfree to be skipped.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/mtd/onenand/samsung.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index 2cf7408..90bd111 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -895,8 +895,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r) {
 		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENOENT;
-		goto ahb_resource_failed;
+		err = -ENOENT;
+		goto resource_failed;
 	}
 
 	onenand->base_res = request_mem_region(r->start, resource_size(r),
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] cw1200: hwio: Remove an unnecessary goto
  2013-06-04 14:44 [PATCH 1/4] swim: Release memory region after incorrect return/goto Joe Perches
  2013-06-04 14:44 ` [PATCH 2/4] inkern: iio_device_put " Joe Perches
  2013-06-04 14:44 ` [PATCH 3/4] mtd: onenand: samsung: Release memory " Joe Perches
@ 2013-06-04 14:44 ` Joe Perches
  2013-06-04 15:09   ` Solomon Peachy
  2013-06-04 18:25 ` [PATCH 1/4] swim: Release memory region after incorrect return/goto Laurent Vivier
  3 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2013-06-04 14:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Solomon Peachy, John W. Linville, linux-wireless, netdev

goto after return is wrong.

The other code in this block needs to set an
error value then goto an error release block.

This one doesn't need to release anything and
was likely a copy/paste remainder.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/wireless/cw1200/hwio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/cw1200/hwio.c b/drivers/net/wireless/cw1200/hwio.c
index 142f45ef..dad3fb3 100644
--- a/drivers/net/wireless/cw1200/hwio.c
+++ b/drivers/net/wireless/cw1200/hwio.c
@@ -178,7 +178,6 @@ int cw1200_indirect_read(struct cw1200_common *priv, u32 addr, void *buf,
 	if ((buf_len / 2) >= 0x1000) {
 		pr_err("Can't read more than 0xfff words.\n");
 		return -EINVAL;
-		goto out;
 	}
 
 	priv->hwbus_ops->lock(priv->hwbus_priv);
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] cw1200: hwio: Remove an unnecessary goto
  2013-06-04 14:44 ` [PATCH 4/4] cw1200: hwio: Remove an unnecessary goto Joe Perches
@ 2013-06-04 15:09   ` Solomon Peachy
  0 siblings, 0 replies; 7+ messages in thread
From: Solomon Peachy @ 2013-06-04 15:09 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, John W. Linville, linux-wireless, netdev

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]

On Tue, Jun 04, 2013 at 07:44:50AM -0700, Joe Perches wrote:
> goto after return is wrong.
> 
> The other code in this block needs to set an
> error value then goto an error release block.
> 
> This one doesn't need to release anything and
> was likely a copy/paste remainder.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Acked-By: Solomon Peachy <pizza@shaftnet.org>

> ---
>  drivers/net/wireless/cw1200/hwio.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/cw1200/hwio.c b/drivers/net/wireless/cw1200/hwio.c
> index 142f45ef..dad3fb3 100644
> --- a/drivers/net/wireless/cw1200/hwio.c
> +++ b/drivers/net/wireless/cw1200/hwio.c
> @@ -178,7 +178,6 @@ int cw1200_indirect_read(struct cw1200_common *priv, u32 addr, void *buf,
>  	if ((buf_len / 2) >= 0x1000) {
>  		pr_err("Can't read more than 0xfff words.\n");
>  		return -EINVAL;
> -		goto out;
>  	}
>  
>  	priv->hwbus_ops->lock(priv->hwbus_priv);
> -- 
> 1.8.1.2.459.gbcd45b4.dirty
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Solomon Peachy        		       pizza at shaftnet dot org	 
Delray Beach, FL                          ^^ (email/xmpp) ^^
Quidquid latine dictum sit, altum viditur.

[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/4] inkern: iio_device_put after incorrect return/goto
  2013-06-04 14:44 ` [PATCH 2/4] inkern: iio_device_put " Joe Perches
@ 2013-06-04 17:28   ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2013-06-04 17:28 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, Jonathan Cameron, linux-iio

On 06/04/2013 03:44 PM, Joe Perches wrote:
> The code uses
> 
>     return foo;
>     goto err_type;
> 
> when instead the form should have been
> 
>     ret = foo;
>     goto err_type;
> 
> Here this causes a useful iio_device_put to be skipped.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
Applied to fixes-togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/inkern.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 795d100..dca4eed 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -124,7 +124,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
>  	channel->indio_dev = indio_dev;
>  	index = iiospec.args_count ? iiospec.args[0] : 0;
>  	if (index >= indio_dev->num_channels) {
> -		return -EINVAL;
> +		err = -EINVAL;
>  		goto err_put;
>  	}
>  	channel->channel = &indio_dev->channels[index];
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] swim: Release memory region after incorrect return/goto
  2013-06-04 14:44 [PATCH 1/4] swim: Release memory region after incorrect return/goto Joe Perches
                   ` (2 preceding siblings ...)
  2013-06-04 14:44 ` [PATCH 4/4] cw1200: hwio: Remove an unnecessary goto Joe Perches
@ 2013-06-04 18:25 ` Laurent Vivier
  3 siblings, 0 replies; 7+ messages in thread
From: Laurent Vivier @ 2013-06-04 18:25 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel

Le 04/06/2013 16:44, Joe Perches a écrit :
> The code uses
>
> 	return foo;
> 	goto err_type;
>
> when instead the form should have been
>
> 	ret = foo;
> 	goto err_type;
>
> Here this causes a useful release_mem_region to be skipped.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>   drivers/block/swim.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/swim.c b/drivers/block/swim.c
> index 2f445b7..8ed6ccb 100644
> --- a/drivers/block/swim.c
> +++ b/drivers/block/swim.c
> @@ -893,7 +893,7 @@ static int swim_probe(struct platform_device *dev)
>   
>   	swim_base = ioremap(res->start, resource_size(res));
>   	if (!swim_base) {
> -		return -ENOMEM;
> +		ret = -ENOMEM;
>   		goto out_release_io;
>   	}
>   

Reviewed-by: Laurent Vivier <Laurent@Vivier.EU>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-06-04 18:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-04 14:44 [PATCH 1/4] swim: Release memory region after incorrect return/goto Joe Perches
2013-06-04 14:44 ` [PATCH 2/4] inkern: iio_device_put " Joe Perches
2013-06-04 17:28   ` Jonathan Cameron
2013-06-04 14:44 ` [PATCH 3/4] mtd: onenand: samsung: Release memory " Joe Perches
2013-06-04 14:44 ` [PATCH 4/4] cw1200: hwio: Remove an unnecessary goto Joe Perches
2013-06-04 15:09   ` Solomon Peachy
2013-06-04 18:25 ` [PATCH 1/4] swim: Release memory region after incorrect return/goto Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).