Skip to content

Commit

Permalink
drm/amd/display: fix pow() crashing when given base 0
Browse files Browse the repository at this point in the history
commit d2e59d0 upstream.

[Why&How]
pow(a,x) is implemented as exp(x*log(a)). log(0) will crash.
So return 0^x = 0, unless x=0, convention seems to be 0^0 = 1.

Cc: stable@vger.kernel.org
Signed-off-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Krunoslav Kovac authored and gregkh committed Aug 26, 2020
1 parent 1f3cfa9 commit 504fe0a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/gpu/drm/amd/display/include/fixed31_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ struct fixed31_32 dc_fixpt_log(struct fixed31_32 arg);
*/
static inline struct fixed31_32 dc_fixpt_pow(struct fixed31_32 arg1, struct fixed31_32 arg2)
{
if (arg1.value == 0)
return arg2.value == 0 ? dc_fixpt_one : dc_fixpt_zero;

return dc_fixpt_exp(
dc_fixpt_mul(
dc_fixpt_log(arg1),
Expand Down

0 comments on commit 504fe0a

Please sign in to comment.