Skip to content

microcom.c: Call cleanup routines only once - #56

Merged
jonrebm merged 1 commit into
pengutronix:mainfrom
jonrebm:cleaup-routines
Oct 19, 2026
Merged

jonrebm merged 1 commit into
pengutronix:mainfrom
jonrebm:cleaup-routines

Conversation

@jonrebm

@jonrebm jonrebm commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Repeated call to ios->exit(ios); was observed as used after free using asan. Only call it once: In the exit handler.

Always call the exit handler and check there whether listenonly is set and there skip resetting the terminal if so.

Do not reset the terminal elsewhere.

Do not call the exit handler from the quit command, call exit instead.

@jonrebm jonrebm mentioned this pull request Dec 14, 2025
@jonrebm

jonrebm commented Jan 14, 2026

Copy link
Copy Markdown
Contributor Author

Has anyone taken a look at this one already? @ukleinek or @a3f maybe?

Comment thread microcom.c Resolved
Comment thread commands.c Resolved
@jonrebm

jonrebm commented Feb 6, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @michaelolbrich. Seems I need to run another round of testing.

@jonrebm

jonrebm commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Applied feedback from @michaelolbrich, made microcom_exit static, rebased to main

Comment thread microcom.c Resolved
Comment thread microcom.c Resolved
Repeated call to ios->exit(ios); was observed as used after free using
asan. Only call it once: In the exit handler.

Always call the exit handler, either via sigaction or via atexit, and
check there whether listenonly is set and there skip resetting the
terminal if so.

Do not reset the terminal elsewhere.

Do not call the exit handler from the quit command, just call exit,
and rely on atexit.

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
@jonrebm
jonrebm merged commit 83462b2 into pengutronix:main Oct 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants