[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200824082416.069469455@linuxfoundation.org>
Date: Mon, 24 Aug 2020 10:29:00 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Krunoslav Kovac <Krunoslav.Kovac@....com>,
Anthony Koo <Anthony.Koo@....com>,
Rodrigo Siqueira <Rodrigo.Siqueira@....com>,
Alex Deucher <alexander.deucher@....com>
Subject: [PATCH 5.8 042/148] drm/amd/display: fix pow() crashing when given base 0
From: Krunoslav Kovac <Krunoslav.Kovac@....com>
commit d2e59d0ff4c44d1f6f8ed884a5bea7d1bb7fd98c 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@...r.kernel.org
Signed-off-by: Krunoslav Kovac <Krunoslav.Kovac@....com>
Reviewed-by: Anthony Koo <Anthony.Koo@....com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@....com>
Signed-off-by: Alex Deucher <alexander.deucher@....com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
drivers/gpu/drm/amd/display/include/fixed31_32.h | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/gpu/drm/amd/display/include/fixed31_32.h
+++ b/drivers/gpu/drm/amd/display/include/fixed31_32.h
@@ -431,6 +431,9 @@ struct fixed31_32 dc_fixpt_log(struct fi
*/
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),
Powered by blists - more mailing lists