aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorPeter Senna Tschudin <peter.senna@gmail.com>2012-09-17 14:05:33 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-09-17 21:09:56 -0400
commit37bb7899ca366dc212b71b150e78566d04808cc0 (patch)
tree4b8385c4636e009141bf508fffccdec03d4d43bf /drivers/target
parent609234e3b6d69315b5cd511b66435d733204e779 (diff)
target: fix return code in target_core_init_configfs error path
This patch fixes error cases within target_core_init_configfs() to properly set ret = -ENOMEM before jumping to the out_global exception path. This was originally discovered with the following Coccinelle semantic match information: 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> Cc: stable@vger.kernel.org Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_configfs.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index a1b41715464a..015f5be27bf6 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)
3124 GFP_KERNEL); 3124 GFP_KERNEL);
3125 if (!target_cg->default_groups) { 3125 if (!target_cg->default_groups) {
3126 pr_err("Unable to allocate target_cg->default_groups\n"); 3126 pr_err("Unable to allocate target_cg->default_groups\n");
3127 ret = -ENOMEM;
3127 goto out_global; 3128 goto out_global;
3128 } 3129 }
3129 3130
@@ -3139,6 +3140,7 @@ static int __init target_core_init_configfs(void)
3139 GFP_KERNEL); 3140 GFP_KERNEL);
3140 if (!hba_cg->default_groups) { 3141 if (!hba_cg->default_groups) {
3141 pr_err("Unable to allocate hba_cg->default_groups\n"); 3142 pr_err("Unable to allocate hba_cg->default_groups\n");
3143 ret = -ENOMEM;
3142 goto out_global; 3144 goto out_global;
3143 } 3145 }
3144 config_group_init_type_name(&alua_group, 3146 config_group_init_type_name(&alua_group,
@@ -3154,6 +3156,7 @@ static int __init target_core_init_configfs(void)
3154 GFP_KERNEL); 3156 GFP_KERNEL);
3155 if (!alua_cg->default_groups) { 3157 if (!alua_cg->default_groups) {
3156 pr_err("Unable to allocate alua_cg->default_groups\n"); 3158 pr_err("Unable to allocate alua_cg->default_groups\n");
3159 ret = -ENOMEM;
3157 goto out_global; 3160 goto out_global;
3158 } 3161 }
3159 3162
@@ -3165,14 +3168,17 @@ static int __init target_core_init_configfs(void)
3165 * Add core/alua/lu_gps/default_lu_gp 3168 * Add core/alua/lu_gps/default_lu_gp
3166 */ 3169 */
3167 lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1); 3170 lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1);
3168 if (IS_ERR(lu_gp)) 3171 if (IS_ERR(lu_gp)) {
3172 ret = -ENOMEM;
3169 goto out_global; 3173 goto out_global;
3174 }
3170 3175
3171 lu_gp_cg = &alua_lu_gps_group; 3176 lu_gp_cg = &alua_lu_gps_group;
3172 lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, 3177 lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
3173 GFP_KERNEL); 3178 GFP_KERNEL);
3174 if (!lu_gp_cg->default_groups) { 3179 if (!lu_gp_cg->default_groups) {
3175 pr_err("Unable to allocate lu_gp_cg->default_groups\n"); 3180 pr_err("Unable to allocate lu_gp_cg->default_groups\n");
3181 ret = -ENOMEM;
3176 goto out_global; 3182 goto out_global;
3177 } 3183 }
3178 3184