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

Commit f4065395 authored by Arun Menon's avatar Arun Menon
Browse files

msm: vidc: Avoid integer overflow for supported bitrate calculation



Supported bitrate is calculated as 40% of clock frequency.
However table[i].freq is an unsigned 32 bit integer. Multiplying
table[i].freq by 40 would cause an integer overflow and hence the
resulting supported_bitrate calculated for that frequency would
be lower. This would result in the frequency being bumped up
higher to meeting the bitrate requirement.

Change-Id: Idbdfd2301a6ad5b1d7ba0b7374375f9856f3e118
Signed-off-by: default avatarArun Menon <avmenon@codeaurora.org>
parent 65bdd3d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1359,7 +1359,7 @@ static unsigned long __get_clock_rate_with_bitrate(struct clock_info *clock,
			continue;

		freq = table[i].freq;
		supported_bitrate = table[i].freq * 40/100;
		supported_bitrate = freq * 40/100;

		if (table[i].freq >= base_freq &&
			supported_bitrate >= instant_bitrate)