Skip to content
Commit e94af5b1 authored by François Baldassari's avatar François Baldassari Committed by Johan Hedberg
Browse files

Litex: clock: Undefined behavior due to unchecked return code



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: default avatarFrançois Baldassari <francois@memfault.com>
parent 9037a708
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment