Skip to content

Commit 2568ab6

Browse files
JiapengLicarlescufi
authored andcommitted
canbus: isotp: fix single frame state machine stuck issue
it is too late to set ctx->state to ISOTP_TX_WAIT_FIN after send_sf because send_state_machine could be called just between `send_sf` and `ctx->state = ISOTP_TX_WAIT_FIN;` in extremely case. like below: ```c ret = send_sf(ctx); -> send_state_machine (irq handler) ctx->state = ISOTP_TX_WAIT_FIN; ``` it will cause isotp_send never return. Signed-off-by: Jiapeng Li <[email protected]>
1 parent 840c976 commit 2568ab6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

subsys/canbus/isotp/isotp.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,8 @@ static void send_state_machine(struct isotp_send_ctx *ctx)
10911091
case ISOTP_TX_ERR:
10921092
LOG_DBG("SM error");
10931093
__fallthrough;
1094+
case ISOTP_TX_SEND_SF:
1095+
__fallthrough;
10941096
case ISOTP_TX_WAIT_FIN:
10951097
if (ctx->filter_id >= 0) {
10961098
can_remove_rx_filter(ctx->can_dev, ctx->filter_id);
@@ -1187,7 +1189,6 @@ static int send(struct isotp_send_ctx *ctx, const struct device *can_dev,
11871189
LOG_DBG("Sending single frame");
11881190
ctx->filter_id = -1;
11891191
ret = send_sf(ctx);
1190-
ctx->state = ISOTP_TX_WAIT_FIN;
11911192
if (ret) {
11921193
return ret == -EAGAIN ?
11931194
ISOTP_N_TIMEOUT_A : ISOTP_N_ERROR;

0 commit comments

Comments
 (0)