target: Misc retval cleanups

Bubble-up retval from iscsi_update_param_value() and
iscsit_ta_authentication().

Other very small retval cleanups.

Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
Andy Grover 2012-07-12 17:34:56 -07:00 committed by Nicholas Bellinger
parent 2dca673b46
commit 617a0c2eb3
2 changed files with 16 additions and 11 deletions

View File

@ -681,7 +681,7 @@ int iscsi_update_param_value(struct iscsi_param *param, char *value)
param->value = kzalloc(strlen(value) + 1, GFP_KERNEL); param->value = kzalloc(strlen(value) + 1, GFP_KERNEL);
if (!param->value) { if (!param->value) {
pr_err("Unable to allocate memory for value.\n"); pr_err("Unable to allocate memory for value.\n");
return -1; return -ENOMEM;
} }
memcpy(param->value, value, strlen(value)); memcpy(param->value, value, strlen(value));

View File

@ -303,6 +303,7 @@ int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
{ {
struct iscsi_param *param; struct iscsi_param *param;
struct iscsi_tiqn *tiqn = tpg->tpg_tiqn; struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
int ret;
spin_lock(&tpg->tpg_state_lock); spin_lock(&tpg->tpg_state_lock);
if (tpg->tpg_state == TPG_STATE_ACTIVE) { if (tpg->tpg_state == TPG_STATE_ACTIVE) {
@ -319,19 +320,19 @@ int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list); param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
if (!param) { if (!param) {
spin_unlock(&tpg->tpg_state_lock); spin_unlock(&tpg->tpg_state_lock);
return -ENOMEM; return -EINVAL;
} }
if (ISCSI_TPG_ATTRIB(tpg)->authentication) { if (ISCSI_TPG_ATTRIB(tpg)->authentication) {
if (!strcmp(param->value, NONE)) if (!strcmp(param->value, NONE)) {
if (iscsi_update_param_value(param, CHAP) < 0) { ret = iscsi_update_param_value(param, CHAP);
spin_unlock(&tpg->tpg_state_lock); if (ret)
return -ENOMEM; goto err;
}
if (iscsit_ta_authentication(tpg, 1) < 0) {
spin_unlock(&tpg->tpg_state_lock);
return -ENOMEM;
} }
ret = iscsit_ta_authentication(tpg, 1);
if (ret < 0)
goto err;
} }
tpg->tpg_state = TPG_STATE_ACTIVE; tpg->tpg_state = TPG_STATE_ACTIVE;
@ -344,6 +345,10 @@ int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
spin_unlock(&tiqn->tiqn_tpg_lock); spin_unlock(&tiqn->tiqn_tpg_lock);
return 0; return 0;
err:
spin_unlock(&tpg->tpg_state_lock);
return ret;
} }
int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force) int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force)
@ -558,7 +563,7 @@ int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
if ((authentication != 1) && (authentication != 0)) { if ((authentication != 1) && (authentication != 0)) {
pr_err("Illegal value for authentication parameter:" pr_err("Illegal value for authentication parameter:"
" %u, ignoring request.\n", authentication); " %u, ignoring request.\n", authentication);
return -1; return -EINVAL;
} }
memset(buf1, 0, sizeof(buf1)); memset(buf1, 0, sizeof(buf1));