Received: by 10.213.65.68 with SMTP id h4csp2776353imn; Mon, 9 Apr 2018 08:51:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx48jl5pFk/GMTVkKmnRU7ZVryDyZ0VXu08ua/DQYa/i0YE9IBRYOrqw3lA8jiDLF6blYcvVf X-Received: by 10.99.2.202 with SMTP id 193mr25731467pgc.117.1523289118280; Mon, 09 Apr 2018 08:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523289118; cv=none; d=google.com; s=arc-20160816; b=FrbZIcIbliSqSg9pmrIheCUnv/vGHo9GpakFJ0A48HoD3Frz+CGAKwqTs1wfokJg9H kwyBCZJnofJiGGJTITlDTailVJxF5OTjwy/l/KsL5MA1gB9j/X2MdxCntsb3y5a0u2SX 5GPhlQ4iNAd9p+kgmIrBRCuvLa+xfPBSn9BzRfK9r+irbYsjivVe6SKGU3QuNu0edUis KWfAxPN+HRHd828p9qliDAPABkyH5ghDOmfsoAMvptS8dp/HazKF9C/dLZRQi86yGhrV 3IaBGQ1+7w08gvWMn4Xxl16GsSDd7iUVmiaZDyf5EgmiPFQeuA4ubqSgAO3+iAYaih/1 kpoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=08rbDWWf9h4OOHCkIrdknv2sVLk2zeL/mZT/paVPadk=; b=b5Szk9DvxOKhu2tCaH+na/mURSNCcpy30Itf1AnE5PCb7QR/13MfLD72BPxb7QqbRA Ig74IospEbxniMaYIffddhA4qJCBMj6KQTk324jJedGENl0HVoPnUrjstv5e/W9gNLYK RRgFL5wFVyQb0hgSAmHMhao5Bd4TqZwboMKawdN/9v7ztF7vZiPTHg2PUYIAxhM8FWwA bsf4gLimpNpTXzNF/cyxa67kTfO8f2XU1+clMlzf1KIfFQnRA2d1AphKUepXQBpyfdUX hCyxoQaGI5PV1KVG6u8B8WtZi+RhgPz5oFmVXCQJwsZt/O+oKP/dDBwy0zVpLvw4Bzzd FfVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si446713pfi.83.2018.04.09.08.51.21; Mon, 09 Apr 2018 08:51:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753301AbeDIPqq (ORCPT + 99 others); Mon, 9 Apr 2018 11:46:46 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34367 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753243AbeDIPqj (ORCPT ); Mon, 9 Apr 2018 11:46:39 -0400 Received: by mail-wm0-f66.google.com with SMTP id w2so18229085wmw.1; Mon, 09 Apr 2018 08:46:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=08rbDWWf9h4OOHCkIrdknv2sVLk2zeL/mZT/paVPadk=; b=BeSifVX9WljRNsxVUA7duWaxKc0cOSHZFZtB5WulJ3GYLzWdX7oHNgHz2I6Z38oDZh C8VHw/DOgjNksvONUvOfZpvDyaBczcTywm39g41CcjWvULcwvp9Khm7ZALBNU1DH8YY7 RKoWynsNdNONVnq5ezj4mvEmPBCtSZydi69BeUPaPIdUpIDViAHmBzqPIdJwwujy2EzX y/ZeyZE9/o0gEtqyjmiOBN9oKpkKfI+epA/4txV02jLi5WXm4/cvMxXuZ6xjc8dsdhcI Egeil76Tw+Fzj+lM4ODYsFI2hJ7M+5flPAEcwVSDJ5ley6yy4fuhptKEFblyIgECSU/O BvBg== X-Gm-Message-State: ALQs6tADt/o9Z9NfQNhsNH7ZHuatL6t+wwHhiBeTIpoElnu0U+izzg8k 2u+EvLycLElL3KI32+7paYA= X-Received: by 10.28.19.13 with SMTP id 13mr366551wmt.89.1523288798208; Mon, 09 Apr 2018 08:46:38 -0700 (PDT) Received: from wintermute.fritz.box (HSI-KBW-078-043-196-194.hsi4.kabel-badenwuerttemberg.de. [78.43.196.194]) by smtp.gmail.com with ESMTPSA id w40sm881163wrc.33.2018.04.09.08.46.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Apr 2018 08:46:37 -0700 (PDT) From: Jan Glauber To: Herbert Xu Cc: "David S . Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Mahipal Challa , Robert Richter , Jan Glauber Subject: [PATCH v2 3/5] crypto: thunderx_zip: Prevent division by zero Date: Mon, 9 Apr 2018 17:45:52 +0200 Message-Id: <20180409154554.7578-4-jglauber@cavium.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180409154554.7578-1-jglauber@cavium.com> References: <20180409154554.7578-1-jglauber@cavium.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Avoid two potential divisions by zero when calculating average values for the zip statistics. Signed-off-by: Jan Glauber Reviewed-by: Robert Richter --- drivers/crypto/cavium/zip/zip_main.c | 9 +++++---- 1 file 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) 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" -- 2.16.2