Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2393196lqp; Sun, 24 Mar 2024 17:29:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2gzuA/NkgMWTR/yQs5MgO579DlJWxFOVxBCS2nE3WiaaNZLdT94nux0qjLZU8duGnPF+tncrAjk+uAMsumygsstwbgku5I82F9eJgJA== X-Google-Smtp-Source: AGHT+IElJeQe1pwDjAaamwf2RV/5TwsHRQTAfERJskyxbvOn8m/oCRjNCRDCcnLGILn6KpsMgSJK X-Received: by 2002:a05:6830:1601:b0:6e4:e514:c3e4 with SMTP id g1-20020a056830160100b006e4e514c3e4mr7149856otr.13.1711326574590; Sun, 24 Mar 2024 17:29:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326574; cv=pass; d=google.com; s=arc-20160816; b=FhCorW1xyd28prDLi59ktoxqiGSV4I4bB6h/TKCuhW1Wj7sdUUEPyz2KG23AyfKvd2 WPcsK1Pph8QxS4rACEcUubdn+hF0O+BSN+TmeodbBsfZx8lrgGGOmpIVwscM73sNw3dg Z+uwwbQ31iJ/Agr3NKClmlafpXqLev4AxRIhrHavyopo1cjiQ9o6mDy34H/3S5KFuMpu +OnlFyCVbe2NuhDakC5Hz8Oa/8hWr7MTzLzDy4+LYgSZW9ULxLVNlyXFgXKzKDufQlu3 Pmlv/7DBam+ssdfhT9gS1czhRwLdrTQOPR97LgHs15fRj2sJSvvqVLVHgjabTRP0083D RQyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yn2CaS2iXqk0qqkDQNXbkL2zezGUfIyF+2Fc6Zc9yP4=; fh=fd39tcrvp7hxb/eBBDrJv4g2sjXJvK9+7fidlxvZgTo=; b=APaei73rvP1pYP5Vg8NsQY4VLYprzIOJWc0lm8os9TqKAsqe250UOsDIly7hRaPCJF NH2uqqcxGhrenu39hkij0iS0+uAF9JTjM6MTh87SwzrwS1EpdrjNEX2BCXNlC7sDBMV8 gvOfQWDQLDfQlTXEFIyfCr1vJ5WfZKA55/y1UDa/mXBjMiEruZRV7Fmftnich3tYM9+j ggnnp2fHedMAZkFXVlKMv4wyxwTuph5i00C+GI979h1D1PI13SLmqZnyNqt6PRmOu4zi Wg+AwkbLW90Vte4dp/mamEPZazpVG1GoB3ig/v3rPaqzreUgJEEfQPWzqGQr1BuWC0/S V6jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eX7BGfNw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113360-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u14-20020a63f64e000000b005f057f3746asi1615046pgj.449.2024.03.24.17.29.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:29:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113360-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eX7BGfNw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113360-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 402B8B224FC for ; Mon, 25 Mar 2024 00:17:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 653EE19C3AF; Sun, 24 Mar 2024 22:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eX7BGfNw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 826EC19BBB7; Sun, 24 Mar 2024 22:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320161; cv=none; b=UMYMjRYEppUCkcKBizUVo2ELMMUK2kYPd6Yu4tB1trWQXH0iLEKFtABx8QQ2qZwb8hlGhCaKeQ1xkpbvAC+W0ZDOC09v5E6c+V1OEVRk50qCVJXMhQp4//MFmH7+jesqieOngxkNZ96EX4Ijrk/Adz6LgmT4PCqDPoXSCKgVbAc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320161; c=relaxed/simple; bh=6NKZ+nns2FDi5/2LhPWcehmggKBZIPf/gzGtIL9UKCE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NyFX8YFVuIbSlxanDJIqV485fC/84m+lOBYu/aZgSx1reTkRloMrEVlqBUB/cdJ4hhNIQ+O0oZan8f1MQlHhS0sR0aCsgko9mM8t6DPaRSPE9MNo6sdCPwe7oCiuZUjQnV27pZpTadovVx1Xsj6C00y6Rz3WCEmYuPl5bIFcB94= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eX7BGfNw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADB8CC433C7; Sun, 24 Mar 2024 22:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320161; bh=6NKZ+nns2FDi5/2LhPWcehmggKBZIPf/gzGtIL9UKCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eX7BGfNwGrsIeiIAhkUsSG8JKXTXL9R3jTPk0ij1Cn4gq0yCX0M8FyoiI/5MCx8gH tPVKIXd2BFtBsrcwy5/oBOowyKEIzVdecc7EFxhKan9P9MAmpJHrvL9ckef24XmOyr nvtw04flbSkCvNuSJ9IGXrfkab/OrHC+pqHDcRUWr7CS9NIGnM/9vfCC4bMFoPAouy Lw35vy5bKIkufecBwjftfo5AlA8xV8/gIKEMfgeqobqLtgl6FjEiwDeeabGG1iX4Lf Z0aB1EbYCUuEpvgCQoHTL1yqt6dumnaz9TXopaKHY0mrbpoFryXqyLNTD3pIWQRnVk 53XdkVhV4ibng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Adam Guerin , Giovanni Cabiddu , Herbert Xu , Sasha Levin Subject: [PATCH 6.8 469/715] crypto: qat - avoid division by zero Date: Sun, 24 Mar 2024 18:30:48 -0400 Message-ID: <20240324223455.1342824-470-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Adam Guerin [ Upstream commit f99fb7d660f7c818105803f1f1915396a14d18ad ] Check if delta_us is not zero and return -EINVAL if it is. delta_us is unlikely to be zero as there is a sleep between the reads of the two timestamps. This is to fix the following warning when compiling the QAT driver using clang scan-build: drivers/crypto/intel/qat/qat_common/adf_clock.c:87:9: warning: Division by zero [core.DivideZero] 87 | temp = DIV_ROUND_CLOSEST_ULL(temp, delta_us); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: e2980ba57e79 ("crypto: qat - add measure clock frequency") Signed-off-by: Adam Guerin Reviewed-by: Giovanni Cabiddu Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/intel/qat/qat_common/adf_clock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/intel/qat/qat_common/adf_clock.c b/drivers/crypto/intel/qat/qat_common/adf_clock.c index 01e0a389e462b..cf89f57de2a70 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_clock.c +++ b/drivers/crypto/intel/qat/qat_common/adf_clock.c @@ -83,6 +83,9 @@ static int measure_clock(struct adf_accel_dev *accel_dev, u32 *frequency) } delta_us = timespec_to_us(&ts3) - timespec_to_us(&ts1); + if (!delta_us) + return -EINVAL; + temp = (timestamp2 - timestamp1) * ME_CLK_DIVIDER * 10; temp = DIV_ROUND_CLOSEST_ULL(temp, delta_us); /* -- 2.43.0