You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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_cookieshould 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.
The text was updated successfully, but these errors were encountered:
ps_fdt_read_path
does not clearly document when the state of thecookie
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 callingps_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 asimx/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:ps_fdt_read_path
to make it clear whenps_fdt_cleanup_cookie
should be called.ps_fdt_read_path
so that thecookie
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, ifps_fdt_cleanup_cookie
is called incorrectly rather than ending up with a double free that just ends up crashing with no visible output.The text was updated successfully, but these errors were encountered: