summaryrefslogtreecommitdiff
path: root/lib/string_helpers.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2015-10-05 16:17:08 +0100
committerMark Brown <broonie@kernel.org>2015-10-05 16:17:08 +0100
commitc2f4160b77f1e12b2c05f2253575617faf0c69d0 (patch)
treea04ab897d2bc2a756d8ef780684538bb993ff4ab /lib/string_helpers.c
parent6ff33f3902c3b1c5d0db6b1e2c70b6d76fba357f (diff)
parent7e50711993552800644a4667daa0f569a7665eca (diff)
Merge tag 'ib-mfd-regulator-v4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd into regulator-tps6105x
Immutable branch between MFD and Regulator due for v4.3
Diffstat (limited to 'lib/string_helpers.c')
-rw-r--r--lib/string_helpers.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 54036ce2e2dd..5939f63d90cd 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -59,7 +59,11 @@ void string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
}
exp = divisor[units] / (u32)blk_size;
- if (size >= exp) {
+ /*
+ * size must be strictly greater than exp here to ensure that remainder
+ * is greater than divisor[units] coming out of the if below.
+ */
+ if (size > exp) {
remainder = do_div(size, divisor[units]);
remainder *= blk_size;
i++;