Skip to content

Commit d2e59d0

Browse files
Krunoslav Kovacalexdeucher
authored andcommitted
drm/amd/display: fix pow() crashing when given base 0
[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: [email protected] Signed-off-by: Krunoslav Kovac <[email protected]> Reviewed-by: Anthony Koo <[email protected]> Acked-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent db0473f commit d2e59d0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/gpu/drm/amd/display/include/fixed31_32.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ struct fixed31_32 dc_fixpt_log(struct fixed31_32 arg);
431431
*/
432432
static inline struct fixed31_32 dc_fixpt_pow(struct fixed31_32 arg1, struct fixed31_32 arg2)
433433
{
434+
if (arg1.value == 0)
435+
return arg2.value == 0 ? dc_fixpt_one : dc_fixpt_zero;
436+
434437
return dc_fixpt_exp(
435438
dc_fixpt_mul(
436439
dc_fixpt_log(arg1),

0 commit comments

Comments
 (0)