Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2924721pxb; Fri, 12 Feb 2021 05:11:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwidFo7DxBaxhR9TEj9vKCvbyvWb0z2Yol7PbugTEKKCbINtHGxrU3gDFTOuIq4beIwsAAw X-Received: by 2002:a05:6402:35ca:: with SMTP id z10mr3363592edc.174.1613135487601; Fri, 12 Feb 2021 05:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613135487; cv=none; d=google.com; s=arc-20160816; b=tphynnV+oTOa+PwV7es+cIbP97mX0FKvcAikDr76p9CqpT/FR+HsqA/J/5iCg4G3M7 yrFILDtNZgcYNRlVKk2X2zmQe5/AU8xgrUmOlpW1yaU8sQOOY56EUPxfqppL3iyP5ag+ qy4kRfoh/dPmrDDIg9hjSLO2jurBPFI3AbL06g4N2Lt8GATkYMNPm9Wa+b832u9d5XMH Kqg5f9WPxNMRhQKJ6Nz2jEb51dBCNzyZ1CWY+UDiZEei1XKDnHzn/LITeThiec8h0N1N IUjNOvde0SNGOpbsQpArt8vNI9edDs+KKKtjD7k4pLtw1nZNSgHe3UDzZ0oyTmQxAiuw 1TfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=yumpIkFbTh86BeACdYqJPqxvrU0QgDo5bkRx9NKggtw=; b=U4kgM3EA1BN/zrVWdeQQaih45kE70R9HuLPpLi2qCXT8TkIQRZU1uXOvf1J3XSYvbp q/k1aQRExMqQ9J3G0au2zA/wncrqLUZaqIHkIosyQMBhzfzAsgkedZgiDGhDVdB0pj8A 5Gt2mUUngg3jCQEiJ/ZYI1MVLCz75ELeR4ZZGMGF+HUBV+2OrS1UWqy1qiHEhGMf3pQD /ibpNnVsq285hAk6HvPkNnJ8KZWKassqUAkvIgHQRGV8vs7A99POSFxhO+BrBwtvXrlr 6ubZvBpe/v7u3LDe3yfVnjcwvRkb+PacFEO4rU/qV/AF8c8h3WYv1Y25vJRP46Zc7Twe 4bZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iy2YldAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si6304465edd.84.2021.02.12.05.11.04; Fri, 12 Feb 2021 05:11:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iy2YldAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231522AbhBLNKd (ORCPT + 99 others); Fri, 12 Feb 2021 08:10:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:58112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbhBLMvO (ORCPT ); Fri, 12 Feb 2021 07:51:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6AE164E16; Fri, 12 Feb 2021 12:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613134231; bh=rnXOqI0luJangx2CzFBf1733EK1II/gZ616cSb9TWZg=; h=Date:From:To:Cc:Subject:From; b=iy2YldALxmZoGeDz+0/8X9gfYRbsSO4ppZjp/fE2Z6KCNV62mebw5FbgKQ/D+DYQP BEvaKe9e+zTafwHYKaO4Ucb3ComLISehaYBVMfySG+/+9Wst2P5Zqkdt3uM4cbMfhf fuM9V50621iZBBWCL22mxZ1L2MXoA9anF/bfV6/zbwTn7W7nTPaoDWcnby1YWQcY7m a2qo4wUKS3DCsguETDISfpmC3aItGXMizuOGMKHE/5vETZrsfhtG2npuLD/8d1tpvZ 69X4z0Uq3oTGZFEsQ3o5OFqnUan/h7DQLumQpv15orV5nDaFwNmLBkO4G+twLnYqov isi/8FntPKnHQ== Date: Fri, 12 Feb 2021 06:50:28 -0600 From: "Gustavo A. R. Silva" To: Coly Li , Kent Overstreet , "David S. Miller" , Christina Jacob , Hariprasad Kelam , Sunil Goutham , Jesse Brandeburg Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH][next] bcache: Use 64-bit arithmetic instead of 32-bit Message-ID: <20210212125028.GA264620@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cast multiple variables to (int64_t) in order to give the compiler complete information about the proper arithmetic to use. Notice that these variables are being used in contexts that expect expressions of type int64_t (64 bit, signed). And currently, such expressions are being evaluated using 32-bit arithmetic. Fixes: d0cf9503e908 ("octeontx2-pf: ethtool fec mode support") Addresses-Coverity-ID: 1501724 ("Unintentional integer overflow") Addresses-Coverity-ID: 1501725 ("Unintentional integer overflow") Addresses-Coverity-ID: 1501726 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva --- drivers/md/bcache/writeback.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index 82d4e0880a99..4fb635c0baa0 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -110,13 +110,13 @@ static void __update_writeback_rate(struct cached_dev *dc) int64_t fps; if (c->gc_stats.in_use <= BCH_WRITEBACK_FRAGMENT_THRESHOLD_MID) { - fp_term = dc->writeback_rate_fp_term_low * + fp_term = (int64_t)dc->writeback_rate_fp_term_low * (c->gc_stats.in_use - BCH_WRITEBACK_FRAGMENT_THRESHOLD_LOW); } else if (c->gc_stats.in_use <= BCH_WRITEBACK_FRAGMENT_THRESHOLD_HIGH) { - fp_term = dc->writeback_rate_fp_term_mid * + fp_term = (int64_t)dc->writeback_rate_fp_term_mid * (c->gc_stats.in_use - BCH_WRITEBACK_FRAGMENT_THRESHOLD_MID); } else { - fp_term = dc->writeback_rate_fp_term_high * + fp_term = (int64_t)dc->writeback_rate_fp_term_high * (c->gc_stats.in_use - BCH_WRITEBACK_FRAGMENT_THRESHOLD_HIGH); } fps = div_s64(dirty, dirty_buckets) * fp_term; -- 2.27.0