diff options
author | Jan Glauber <jglauber@cavium.com> | 2018-04-09 11:45:52 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-04-20 12:58:35 -0400 |
commit | a40c88045506ecba8e3ae75da19e8a2c53e23a41 (patch) | |
tree | 5a8938ec0845cba8131a3e89e97d8e91fb255cef | |
parent | c782a8c43e94ba6c09e9de2d69b5e3a5840ce61c (diff) |
crypto: cavium - Prevent division by zero
Avoid two potential divisions by zero when calculating average
values for the zip statistics.
Signed-off-by: Jan Glauber <jglauber@cavium.com>
Reviewed-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/cavium/zip/zip_main.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/crypto/cavium/zip/zip_main.c b/drivers/crypto/cavium/zip/zip_main.c index 1cd8aa488185..79b449e0f955 100644 --- a/drivers/crypto/cavium/zip/zip_main.c +++ b/drivers/crypto/cavium/zip/zip_main.c | |||
@@ -482,10 +482,11 @@ static int zip_show_stats(struct seq_file *s, void *unused) | |||
482 | atomic64_add(val, &st->pending_req); | 482 | atomic64_add(val, &st->pending_req); |
483 | } | 483 | } |
484 | 484 | ||
485 | avg_chunk = (atomic64_read(&st->comp_in_bytes) / | 485 | val = atomic64_read(&st->comp_req_complete); |
486 | atomic64_read(&st->comp_req_complete)); | 486 | avg_chunk = (val) ? atomic64_read(&st->comp_in_bytes) / val : 0; |
487 | avg_cr = (atomic64_read(&st->comp_in_bytes) / | 487 | |
488 | atomic64_read(&st->comp_out_bytes)); | 488 | val = atomic64_read(&st->comp_out_bytes); |
489 | avg_cr = (val) ? atomic64_read(&st->comp_in_bytes) / val : 0; | ||
489 | seq_printf(s, " ZIP Device %d Stats\n" | 490 | seq_printf(s, " ZIP Device %d Stats\n" |
490 | "-----------------------------------\n" | 491 | "-----------------------------------\n" |
491 | "Comp Req Submitted : \t%lld\n" | 492 | "Comp Req Submitted : \t%lld\n" |