|
From: Tony B. <to...@cy...> - 2025-09-02 17:18:06
|
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 <to...@cy...>
---
scst/src/dev_handlers/scst_user.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c
index cfd9ce21d..88b37eb3d 100644
--- a/scst/src/dev_handlers/scst_user.c
+++ b/scst/src/dev_handlers/scst_user.c
@@ -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:
--
2.43.0
|