linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/target/target_core_configfs.c: fix error return code
@ 2012-09-17 18:05 Peter Senna Tschudin
  2012-09-18  1:23 ` Nicholas A. Bellinger
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Senna Tschudin @ 2012-09-17 18:05 UTC (permalink / raw)
  To: linux-scsi
  Cc: target-devel, linux-kernel, kernel-janitors, Peter Senna Tschudin

From: Peter Senna Tschudin <peter.senna@gmail.com>

Convert a nonnegative error return code to a negative one, as returned
elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}
// </smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
 drivers/target/target_core_configfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index a1b4171..015f5be 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -3124,6 +3124,7 @@ static int __init target_core_init_configfs(void)
 				GFP_KERNEL);
 	if (!target_cg->default_groups) {
 		pr_err("Unable to allocate target_cg->default_groups\n");
+		ret = -ENOMEM;
 		goto out_global;
 	}
 
@@ -3139,6 +3140,7 @@ static int __init target_core_init_configfs(void)
 				GFP_KERNEL);
 	if (!hba_cg->default_groups) {
 		pr_err("Unable to allocate hba_cg->default_groups\n");
+		ret = -ENOMEM;
 		goto out_global;
 	}
 	config_group_init_type_name(&alua_group,
@@ -3154,6 +3156,7 @@ static int __init target_core_init_configfs(void)
 			GFP_KERNEL);
 	if (!alua_cg->default_groups) {
 		pr_err("Unable to allocate alua_cg->default_groups\n");
+		ret = -ENOMEM;
 		goto out_global;
 	}
 
@@ -3165,14 +3168,17 @@ static int __init target_core_init_configfs(void)
 	 * Add core/alua/lu_gps/default_lu_gp
 	 */
 	lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1);
-	if (IS_ERR(lu_gp))
+	if (IS_ERR(lu_gp)) {
+		ret = -ENOMEM;
 		goto out_global;
+	}
 
 	lu_gp_cg = &alua_lu_gps_group;
 	lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
 			GFP_KERNEL);
 	if (!lu_gp_cg->default_groups) {
 		pr_err("Unable to allocate lu_gp_cg->default_groups\n");
+		ret = -ENOMEM;
 		goto out_global;
 	}
 
-- 
1.7.11.4


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

* Re: [PATCH] drivers/target/target_core_configfs.c: fix error return code
  2012-09-17 18:05 [PATCH] drivers/target/target_core_configfs.c: fix error return code Peter Senna Tschudin
@ 2012-09-18  1:23 ` Nicholas A. Bellinger
  0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2012-09-18  1:23 UTC (permalink / raw)
  To: Peter Senna Tschudin
  Cc: linux-scsi, target-devel, linux-kernel, kernel-janitors

On Mon, 2012-09-17 at 20:05 +0200, Peter Senna Tschudin wrote:
> From: Peter Senna Tschudin <peter.senna@gmail.com>
> 
> Convert a nonnegative error return code to a negative one, as returned
> elsewhere in the function.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 

<SNIP>

> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
> ---

This bug-fix patch with a slightly more verbose commit log has been
applied to target-pending/for-next, along with a CC' to stable so it
get's picked up for v3.6.1 + friends.

Thanks Peter!

--nab

>  drivers/target/target_core_configfs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index a1b4171..015f5be 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -3124,6 +3124,7 @@ static int __init target_core_init_configfs(void)
>  				GFP_KERNEL);
>  	if (!target_cg->default_groups) {
>  		pr_err("Unable to allocate target_cg->default_groups\n");
> +		ret = -ENOMEM;
>  		goto out_global;
>  	}
>  
> @@ -3139,6 +3140,7 @@ static int __init target_core_init_configfs(void)
>  				GFP_KERNEL);
>  	if (!hba_cg->default_groups) {
>  		pr_err("Unable to allocate hba_cg->default_groups\n");
> +		ret = -ENOMEM;
>  		goto out_global;
>  	}
>  	config_group_init_type_name(&alua_group,
> @@ -3154,6 +3156,7 @@ static int __init target_core_init_configfs(void)
>  			GFP_KERNEL);
>  	if (!alua_cg->default_groups) {
>  		pr_err("Unable to allocate alua_cg->default_groups\n");
> +		ret = -ENOMEM;
>  		goto out_global;
>  	}
>  
> @@ -3165,14 +3168,17 @@ static int __init target_core_init_configfs(void)
>  	 * Add core/alua/lu_gps/default_lu_gp
>  	 */
>  	lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1);
> -	if (IS_ERR(lu_gp))
> +	if (IS_ERR(lu_gp)) {
> +		ret = -ENOMEM;
>  		goto out_global;
> +	}
>  
>  	lu_gp_cg = &alua_lu_gps_group;
>  	lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
>  			GFP_KERNEL);
>  	if (!lu_gp_cg->default_groups) {
>  		pr_err("Unable to allocate lu_gp_cg->default_groups\n");
> +		ret = -ENOMEM;
>  		goto out_global;
>  	}
>  



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

end of thread, other threads:[~2012-09-18  1:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-17 18:05 [PATCH] drivers/target/target_core_configfs.c: fix error return code Peter Senna Tschudin
2012-09-18  1:23 ` Nicholas A. Bellinger

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).