Skip to content
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

ps_fdt_read_path error handling inconsistent #49

Open
bennoleslie opened this issue Sep 27, 2020 · 0 comments
Open

ps_fdt_read_path error handling inconsistent #49

bennoleslie opened this issue Sep 27, 2020 · 0 comments

Comments

@bennoleslie
Copy link

ps_fdt_read_path does not clearly document when the state of the cookie and initialization in cases when an error is returned.

This has led to some call-sites checking the error and then calling ps_fdt_cleanup_cookie, and other call-sites not calling ps_fdt_cleanup_cookie.

From examination of the implementation is is clear that ps_fdt_cleanup_cookie should not be called in the cases where an error is returned. So the code that does do this cleanup (such as imx/gpt.c) should be fixed to omit the call to cleanup.
The current behaviour is such that we end up with a double free, which is very difficult to debug.

In addition, to fixing the existing incorrect calls to ps_fdt_cleanup_cookie I'd suggest the following improvements:

  • Update documentation of ps_fdt_read_path to make it clear when ps_fdt_cleanup_cookie should be called.
  • Update implementation of ps_fdt_read_path so that the cookie output variable is only populated in the case of success (or explicitly populated will NULL on the case of failure). Such a change would make it clearer to callers whether or not to call cleanup, and would hit NULL-pointer check asserts, if ps_fdt_cleanup_cookie is called incorrectly rather than ending up with a double free that just ends up crashing with no visible output.
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

No branches or pull requests

1 participant