Commit 17c45b90 authored by Markus Elfring's avatar Markus Elfring Committed by Nicholas Bellinger

iSCSI-target: Use common error handling code in iscsi_decode_text_input()

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 6eaf69e4
...@@ -1380,10 +1380,8 @@ int iscsi_decode_text_input( ...@@ -1380,10 +1380,8 @@ int iscsi_decode_text_input(
char *key, *value; char *key, *value;
struct iscsi_param *param; struct iscsi_param *param;
if (iscsi_extract_key_value(start, &key, &value) < 0) { if (iscsi_extract_key_value(start, &key, &value) < 0)
kfree(tmpbuf); goto free_buffer;
return -1;
}
pr_debug("Got key: %s=%s\n", key, value); pr_debug("Got key: %s=%s\n", key, value);
...@@ -1396,38 +1394,37 @@ int iscsi_decode_text_input( ...@@ -1396,38 +1394,37 @@ int iscsi_decode_text_input(
param = iscsi_check_key(key, phase, sender, param_list); param = iscsi_check_key(key, phase, sender, param_list);
if (!param) { if (!param) {
if (iscsi_add_notunderstood_response(key, if (iscsi_add_notunderstood_response(key, value,
value, param_list) < 0) { param_list) < 0)
kfree(tmpbuf); goto free_buffer;
return -1;
}
start += strlen(key) + strlen(value) + 2; start += strlen(key) + strlen(value) + 2;
continue; continue;
} }
if (iscsi_check_value(param, value) < 0) { if (iscsi_check_value(param, value) < 0)
kfree(tmpbuf); goto free_buffer;
return -1;
}
start += strlen(key) + strlen(value) + 2; start += strlen(key) + strlen(value) + 2;
if (IS_PSTATE_PROPOSER(param)) { if (IS_PSTATE_PROPOSER(param)) {
if (iscsi_check_proposer_state(param, value) < 0) { if (iscsi_check_proposer_state(param, value) < 0)
kfree(tmpbuf); goto free_buffer;
return -1;
}
SET_PSTATE_RESPONSE_GOT(param); SET_PSTATE_RESPONSE_GOT(param);
} else { } else {
if (iscsi_check_acceptor_state(param, value, conn) < 0) { if (iscsi_check_acceptor_state(param, value, conn) < 0)
kfree(tmpbuf); goto free_buffer;
return -1;
}
SET_PSTATE_ACCEPTOR(param); SET_PSTATE_ACCEPTOR(param);
} }
} }
kfree(tmpbuf); kfree(tmpbuf);
return 0; return 0;
free_buffer:
kfree(tmpbuf);
return -1;
} }
int iscsi_encode_text_output( int iscsi_encode_text_output(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment