netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jose Abreu <Jose.Abreu@synopsys.com>
To: Colin Ian King <colin.king@canonical.com>,
	"David S. Miller" <davem@davemloft.net>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: net: stmmac: Add basic EST support for GMAC5+
Date: Thu, 26 Dec 2019 17:14:20 +0000	[thread overview]
Message-ID: <BN8PR12MB326646266EF7CEA29685CF0AD32B0@BN8PR12MB3266.namprd12.prod.outlook.com> (raw)
In-Reply-To: <c1b6b4cc-bc94-8ed6-0098-de9e5321722a@canonical.com>

From: Colin Ian King <colin.king@canonical.com>
Date: Dec/20/2019, 23:49:02 (UTC+00:00)

> Hi,
> 
> Static analysis with Coverity has detected a potential issue with the
> following commit:
> 
> commit 504723af0d85434be5fb6f2dde0b62644a7f1ead
> Author: Jose Abreu <joabreu@synopsys.com>
> Date:   Wed Dec 18 11:33:05 2019 +0100
> 
>     net: stmmac: Add basic EST support for GMAC5+
> 
> 
> In function dwmac5_est_configure() we have a u64 total_ctr being
> assigned as follows:
> 
> 	total_ctr = cfg->ctr[0] + cfg->ctr[1] * 1000000000;
> 
> The cfg->ctr[1] is a u32, the multiplication of cfg->ctr[1] is a u32
> multiplication operation, so multiplying by 1000000000 can potentially
> cause an overflow.  Either cfg->ctr[1] needs to be cast to a u64 or
> 1000000000 should be at least a 1000000000UL to avoid this overflow. I
> was going to fix this but on further inspection I was not sure if the
> original code was intended as:
> 
> 	total_ctr = cfg->ctr[0] + cfg->ctr[1] * 1000000000UL;
> or:
> 	total_ctr = (cfg->ctr[0] + cfg->ctr[1]) * 1000000000UL;
> 
> ..hence I'm flagging this up as potential error.

Thanks for the report. The first option is the correct one as ctr[1] is 
seconds and ctr[0] is nanoseconds. Can you send a fix-up patch ?

---
Thanks,
Jose Miguel Abreu

      reply	other threads:[~2019-12-26 17:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 23:49 net: stmmac: Add basic EST support for GMAC5+ Colin Ian King
2019-12-26 17:14 ` Jose Abreu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN8PR12MB326646266EF7CEA29685CF0AD32B0@BN8PR12MB3266.namprd12.prod.outlook.com \
    --to=jose.abreu@synopsys.com \
    --cc=alexandre.torgue@st.com \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).