From: Florinel Iordache <florinel.iordache@nxp.com>
To: madalin.bucur@nxp.com, davem@davemloft.net, kuba@kernel.org,
netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Florinel Iordache <florinel.iordache@nxp.com>
Subject: [PATCH net v3 1/5] fsl/fman: use 32-bit unsigned integer
Date: Mon, 3 Aug 2020 10:07:30 +0300 [thread overview]
Message-ID: <1596438454-4895-2-git-send-email-florinel.iordache@nxp.com> (raw)
In-Reply-To: <1596438454-4895-1-git-send-email-florinel.iordache@nxp.com>
Potentially overflowing expression (ts_freq << 16 and intgr << 16)
declared as type u32 (32-bit unsigned) is evaluated using 32-bit
arithmetic and then used in a context that expects an expression of
type u64 (64-bit unsigned) which ultimately is used as 16-bit
unsigned by typecasting to u16. Fixed by using an unsigned 32-bit
integer since the value is truncated anyway in the end.
Fixes: 414fd46e7762 ("fsl/fman: Add FMan support")
Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
---
drivers/net/ethernet/freescale/fman/fman.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c
index f151d6e..ef67e85 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -1398,8 +1398,7 @@ static void enable_time_stamp(struct fman *fman)
{
struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs;
u16 fm_clk_freq = fman->state->fm_clk_freq;
- u32 tmp, intgr, ts_freq;
- u64 frac;
+ u32 tmp, intgr, ts_freq, frac;
ts_freq = (u32)(1 << fman->state->count1_micro_bit);
/* configure timestamp so that bit 8 will count 1 microsecond
--
1.9.1
next prev parent reply other threads:[~2020-08-03 7:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-03 7:07 [PATCH net v3 0/5] DPAA FMan driver fixes Florinel Iordache
2020-08-03 7:07 ` Florinel Iordache [this message]
2020-08-03 7:07 ` [PATCH net v3 2/5] fsl/fman: fix dereference null return value Florinel Iordache
2020-08-03 7:07 ` [PATCH net v3 3/5] fsl/fman: fix unreachable code Florinel Iordache
2020-08-03 7:07 ` [PATCH net v3 4/5] fsl/fman: check dereferencing null pointer Florinel Iordache
2020-08-03 7:07 ` [PATCH net v3 5/5] fsl/fman: fix eth hash table allocation Florinel Iordache
2020-08-03 8:26 ` [PATCH net v3 0/5] DPAA FMan driver fixes Madalin Bucur (OSS)
2020-08-03 23:20 ` David Miller
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=1596438454-4895-2-git-send-email-florinel.iordache@nxp.com \
--to=florinel.iordache@nxp.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
/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).