-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Litex: clock: Undefined behavior due to unchecked return code #71728
Conversation
7d5bec3
to
47256b2
Compare
Please rebase to retrigger CI @mateusz-holenko @kgugala please take a look |
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.
LGTM
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 fine to me
Found via static analysis. Two separate error paths where failing to check the return code leads to undefined behavior: 1. In `litex_clk_get_phase`, the divider stays set to 0 when `litex_clk_get_clkout_divider` errors out, which leads to a division by 0. 2. In `litex_clk_calc_duty_normal`, the `duty` struct is used uninitialized if `litex_clk_get_duty_cycle` errors out. In both case, checking the return code and returning early resolves the issue. Signed-off-by: François Baldassari <[email protected]>
rebased to trigger CI |
re-assigning as per recent update to MAINTAINERS.yml |
Found via static analysis. Two separate error paths where failing to check the return code leads to undefined behavior:
litex_clk_get_phase
, the divider stays set to 0 whenlitex_clk_get_clkout_divider
errors out, which leads to a division by 0.litex_clk_calc_duty_normal
, theduty
struct is used uninitialized iflitex_clk_get_duty_cycle
errors out.In both case, checking the return code and returning early resolves the issue.