diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2017-11-03 17:20:38 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2017-11-04 18:17:49 -0400 |
commit | 17c45b90061a76fceadffbce8d85a9107a05a918 (patch) | |
tree | 1cde10f95cc4104ed3a367250e2d1c047ca0d6a9 | |
parent | 6eaf69e4ec075f5af236c0c89f75639a195db904 (diff) |
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: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/iscsi/iscsi_target_parameters.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c index caab1045742d..29a37b242d30 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.c +++ b/drivers/target/iscsi/iscsi_target_parameters.c | |||
@@ -1380,10 +1380,8 @@ int iscsi_decode_text_input( | |||
1380 | char *key, *value; | 1380 | char *key, *value; |
1381 | struct iscsi_param *param; | 1381 | struct iscsi_param *param; |
1382 | 1382 | ||
1383 | if (iscsi_extract_key_value(start, &key, &value) < 0) { | 1383 | if (iscsi_extract_key_value(start, &key, &value) < 0) |
1384 | kfree(tmpbuf); | 1384 | goto free_buffer; |
1385 | return -1; | ||
1386 | } | ||
1387 | 1385 | ||
1388 | pr_debug("Got key: %s=%s\n", key, value); | 1386 | pr_debug("Got key: %s=%s\n", key, value); |
1389 | 1387 | ||
@@ -1396,38 +1394,37 @@ int iscsi_decode_text_input( | |||
1396 | 1394 | ||
1397 | param = iscsi_check_key(key, phase, sender, param_list); | 1395 | param = iscsi_check_key(key, phase, sender, param_list); |
1398 | if (!param) { | 1396 | if (!param) { |
1399 | if (iscsi_add_notunderstood_response(key, | 1397 | if (iscsi_add_notunderstood_response(key, value, |
1400 | value, param_list) < 0) { | 1398 | param_list) < 0) |
1401 | kfree(tmpbuf); | 1399 | goto free_buffer; |
1402 | return -1; | 1400 | |
1403 | } | ||
1404 | start += strlen(key) + strlen(value) + 2; | 1401 | start += strlen(key) + strlen(value) + 2; |
1405 | continue; | 1402 | continue; |
1406 | } | 1403 | } |
1407 | if (iscsi_check_value(param, value) < 0) { | 1404 | if (iscsi_check_value(param, value) < 0) |
1408 | kfree(tmpbuf); | 1405 | goto free_buffer; |
1409 | return -1; | ||
1410 | } | ||
1411 | 1406 | ||
1412 | start += strlen(key) + strlen(value) + 2; | 1407 | start += strlen(key) + strlen(value) + 2; |
1413 | 1408 | ||
1414 | if (IS_PSTATE_PROPOSER(param)) { | 1409 | if (IS_PSTATE_PROPOSER(param)) { |
1415 | if (iscsi_check_proposer_state(param, value) < 0) { | 1410 | if (iscsi_check_proposer_state(param, value) < 0) |
1416 | kfree(tmpbuf); | 1411 | goto free_buffer; |
1417 | return -1; | 1412 | |
1418 | } | ||
1419 | SET_PSTATE_RESPONSE_GOT(param); | 1413 | SET_PSTATE_RESPONSE_GOT(param); |
1420 | } else { | 1414 | } else { |
1421 | if (iscsi_check_acceptor_state(param, value, conn) < 0) { | 1415 | if (iscsi_check_acceptor_state(param, value, conn) < 0) |
1422 | kfree(tmpbuf); | 1416 | goto free_buffer; |
1423 | return -1; | 1417 | |
1424 | } | ||
1425 | SET_PSTATE_ACCEPTOR(param); | 1418 | SET_PSTATE_ACCEPTOR(param); |
1426 | } | 1419 | } |
1427 | } | 1420 | } |
1428 | 1421 | ||
1429 | kfree(tmpbuf); | 1422 | kfree(tmpbuf); |
1430 | return 0; | 1423 | return 0; |
1424 | |||
1425 | free_buffer: | ||
1426 | kfree(tmpbuf); | ||
1427 | return -1; | ||
1431 | } | 1428 | } |
1432 | 1429 | ||
1433 | int iscsi_encode_text_output( | 1430 | int iscsi_encode_text_output( |