RE: [PATCH v3 2/2] clk:mmp: clk-mix.c fix divide-by-zero

From: Nixiaoming
Date: Wed Apr 24 2019 - 11:35:05 EST


On Wed, Apr 24, 2019 at 7:00 AM Stephen Boyd <sboyd@xxxxxxxxxx> wrote:
>Quoting nixiaoming (2019-03-30 06:55:42)
>> The _get_div() function has a branch with a return value of 0
>> Add a check on the return value of _get_div() to avoid divide-by-zero
>>
>
>Are you seeing this in practice? Or just trying to avoid a div-by-zero
>case that you've found from inspection?
>
This potential bug is found by code inspection.
_get_div() is defined as a static function which is only refered twice
in drivers/clk/mmp/clk-mix.c. In both cases the return value of _get_div()
is used as divider without any check.
If _get_div() never returns 0, then the branch returning 0 is dead code,
or the return value should be check to avoid dividing by zero error.

thanks

>> Signed-off-by: nixiaoming <nixiaoming@xxxxxxxxxx>
>> Reviewed-by: Mukesh Ojha <mojha@xxxxxxxxxxxxxx>
>