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

Commit a40c8804 authored by Jan Glauber's avatar Jan Glauber Committed by Herbert Xu
Browse files

crypto: cavium - Prevent division by zero



Avoid two potential divisions by zero when calculating average
values for the zip statistics.

Signed-off-by: default avatarJan Glauber <jglauber@cavium.com>
Reviewed-by: default avatarRobert Richter <rrichter@cavium.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c782a8c4
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -482,10 +482,11 @@ static int zip_show_stats(struct seq_file *s, void *unused)
				atomic64_add(val, &st->pending_req);
			}

			avg_chunk = (atomic64_read(&st->comp_in_bytes) /
				     atomic64_read(&st->comp_req_complete));
			avg_cr = (atomic64_read(&st->comp_in_bytes) /
				  atomic64_read(&st->comp_out_bytes));
			val = atomic64_read(&st->comp_req_complete);
			avg_chunk = (val) ? atomic64_read(&st->comp_in_bytes) / val : 0;

			val = atomic64_read(&st->comp_out_bytes);
			avg_cr = (val) ? atomic64_read(&st->comp_in_bytes) / val : 0;
			seq_printf(s, "        ZIP Device %d Stats\n"
				      "-----------------------------------\n"
				      "Comp Req Submitted        : \t%lld\n"