-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: smf: add NULL check in smf_execute_all_exit_actions #73632
Conversation
Like in smf_execute_all_entry_actions(), add NULL check in smf_execute_all_exit_actions(). Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. It would be appreciated if you could extend one of the existing test cases to verify this behavior.
Tagging @glenn-andrews for your visibility. If you want to nominate yourself as a collaborator on the SMF, you will automatically get added to PRs that touch the SMF. |
What was the situation where this error occurred?
We may have a deeper error with determining |
Done: #73729 |
Per my check, |
addressed |
Good find. With this fix, is the null check still needed? |
It becomes unnecessary. I keep it there because it does no harm. If concerned, I can remove the null check. |
lib/smf/smf.c
Outdated
@@ -98,12 +98,12 @@ static bool smf_execute_all_entry_actions(struct smf_ctx *const ctx, | |||
for (const struct smf_state *to_execute = get_child_of(new_state, topmost); | |||
to_execute != NULL && to_execute != new_state; | |||
to_execute = get_child_of(new_state, to_execute)) { | |||
/* Keep track of the executing entry action in case it calls | |||
* smf_set_State() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* smf_set_State() | |
* smf_set_state() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
It adds another check to an already-long if statement, and gets called for every parent. But that's still trivial compared to the CPU cycles we waste trying to find the LCA before this function gets called. Feel free to leave it in. |
Fix ctx->executing is not updated in smf_execute_all_entry_actions() Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
d7e4140
to
cf922f2
Compare
I keep the null check there if no other concern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Like in
smf_execute_all_entry_actions()
, add NULL check insmf_execute_all_exit_actions()
.