X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2Fstring_helpers.c;h=5939f63d90cde79fe1e09814765539a7e43a3c28;hb=b97e6de9c96cefaa02a6a7464731ea504b45e150;hp=54036ce2e2dd0a4ab042c9c19b2d54fa41a34115;hpb=06a660ada2064bbdcd09aeb8173f2ad128c71978;p=firefly-linux-kernel-4.4.55.git 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++;