Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6c2cb12 authored by Animesh Kishore's avatar Animesh Kishore Committed by raghavendra ambadas
Browse files

mdss: mdp: Fix fudge factor overflow check



Fudge adjustment is always 64 bit operation
irrespective of underlying architecture is
32/64 bit. Fix max value to compare overflow
against. Add warning if adjustments can't go
through without overflow.

Change-Id: I9c15ea8c1754c9ddb997546dc476bb6d45198524
Signed-off-by: default avatarAnimesh Kishore <animeshk@codeaurora.org>
parent 994ee63f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -76,13 +76,15 @@ static inline u64 fudge_factor(u64 val, u32 numer, u32 denom)
	u64 result = val;

	if (val) {
		u64 temp = -1UL;
		u64 temp = U64_MAX;

		do_div(temp, val);
		if (temp > numer) {
			/* no overflow, so we can do the operation*/
			result = (val * (u64)numer);
			do_div(result, denom);
		} else {
			pr_warn("Overflow, skip fudge factor\n");
		}
	}
	return result;