Skip to contentSkip to conversation

FAILED: patch "[PATCH] drm/amd/display: fix pow() crashing when given base 0" failed to apply to 5.9-stable tree

PATCH [email protected] 1 participant 1 message Nov 3, 2020

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 5ab7943187f22b572fd12d517bd699771b88ce91 Mon Sep 17 00:00:00 2001
From: Krunoslav Kovac <[email protected]>
Date: Thu, 6 Aug 2020 17:54:47 -0400
Subject: [PATCH] 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.

drivers/gpu/drm/amd/display/include/fixed31_32.h +3 -0
index 89ef9f6860e5..16df2a485dd0 100644
@@ -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),