scst_user: Fix oops in SCST_USER_PARSE_EXCEPTION

If dev->generic_parse() detects a math overflow and calls
scst_set_cmd_error(), and scst_user is using SCST_USER_PARSE_EXCEPTION,
then it will trigger a sBUG() in scst_targ.c::scst_parse_cmd() where it
checks for a valid cmd->state:

scst: scst_parse_cmd:1385:***CRITICAL ERROR***: Bad state for completed cmd
(cmd 000000005abc21e1, state 1)
BUG at /usr/src/debug/scst/3.10+git/scst/src/scst_targ.c:1387

Fix by treating negative generic_parse() errors as final.

Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
This commit is contained in:
Tony Battersby
2025-09-08 16:40:12 +03:00
committed by Gleb Chesnokov
parent f9de3f4169
commit 70e0d81436
+9
View File
@@ -757,6 +757,15 @@ static int dev_user_parse(struct scst_cmd *cmd)
res = SCST_CMD_STATE_NEED_THREAD_CTX;
goto out;
}
if (rc < 0) {
/*
* May have already called e.g. scst_set_cmd_error();
* too late to try user parse without cleaning up
* first.
*/
PRINT_ERROR("PARSE failed (ucmd %p, rc %d)", ucmd, rc);
goto out_error;
}
fallthrough;
case SCST_USER_PARSE_CALL: